package com.handinfo.android.ui.window;

import java.io.DataInputStream;
import java.io.IOException;
import java.text.Format;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.widget.Toast;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.graphics.DWGraphics;
import com.handinfo.android.core.object.Actor;
import com.handinfo.android.core.object.Animation;
import com.handinfo.android.game.GameMessage;
import com.handinfo.android.game.IIcon;
import com.handinfo.android.game.IconManger;
import com.handinfo.android.game.Role;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.SimpleRole;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWAnimationBox;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWGrid;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWInputBox;
import com.handinfo.android.uicontrols.controls.DWLabel;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWMessageBox;
import com.handinfo.android.uicontrols.controls.DWPercentBar;
import com.handinfo.android.uicontrols.controls.DWPopMenu;
import com.handinfo.android.uicontrols.controls.DWTabControl;
import com.handinfo.android.uicontrols.controls.DWTabPage;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

public class UIFamilyWindow implements IUIWindows
{
	public static final byte MAINWINDOW = 0;
	public static final byte QIFUWINDOW = 1;
	private boolean m_frame_isFirst = true;
	private byte m_family_position = -1;
	private Bitmap closeWimdow; //关闭窗口图标
	private Bitmap buttonImg; //按钮图标
	private Bitmap anxiabutonImg;//按钮按下图片
	private Bitmap popMenuImg;
	private Bitmap popAnxiaMenuImg;
	private Bitmap tabSelectImg;// 选项卡选中的图标
	private Bitmap tabUnSelectImg;// 先选卡未被选中的图标
	private Bitmap messageBackground;
	private Bitmap qifuBoxImg;
	private Bitmap foregroundImg;
	private Bitmap backgroundImg;
	private Bitmap nextlv;
	private Bitmap listTitle;
	private Bitmap beforePage;
	private Bitmap nextPage;
	private Bitmap xiaoBackground;
	private Bitmap titleImg;
	private Bitmap msgBackground;

	private final String[] m_tabName = { "成员","家族技能", "等级", "管理", "祈福" };
	private DWFrame m_family_Frame;
	private DWTitle m_family_Title;
	private DWTabControl m_family_TabControl;
	private DWTabPage[] m_family_pages = new DWTabPage[m_tabName.length];
	private DWImageBox m_family_Close;
	private DWBackground m_family_windowBackground;
	
	private static final int CHENGYUAN = 0;
	private static final int JINENG = 1;
	private static final int DENGJI = 2;
	private static final int GUANLI = 3;
	private static final int QIFU = 4;
	//是否第一次打开家族技能
	public static boolean m_isFirstOpenSkill = true;

	public Family m_family = new Family();
	private int netlock = 0;

	public void init()
	{
		msgBackground = UIWindows.createImage("/img/newui/beibaobj_2.gnp");
		closeWimdow = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp");
		buttonImg = UIWindows.createImage("/img/newui/anniu_1.gnp");
		anxiabutonImg = UIWindows.createImage("/img/newui/anniu_1ax.gnp");
		popMenuImg = UIWindows.createImage("/img/newui/anniu_6.gnp");
		popAnxiaMenuImg = UIWindows.createImage("/img/newui/anniu_6ax.gnp");
		tabSelectImg = UIWindows.createImage("/img/newui/biaoqianye_2.gnp");// 选项卡选中的图标
		tabUnSelectImg = UIWindows.createImage("/img/newui/biaoqianye_1.gnp");// 先选卡未被选中的图标
		messageBackground = UIWindows.createImage("/img/newui/jinengtf_1.gnp");
		qifuBoxImg = UIWindows.createImage("/img/newui/wupinlan.gnp");
		foregroundImg = UIWindows.createImage("/img/newui/shangchengjdt_2.gnp");
		backgroundImg = UIWindows.createImage("/img/newui/shangchengjdt_1.gnp");
		nextlv = UIWindows.createImage("/img/newui/tiangongfangzbrljt_1.gnp");
		listTitle = UIWindows.createImage("/img/newui/denglubtk_1.gnp");
		beforePage = UIWindows.createImage("/img/newui/haoyoufyan_2.gnp");
		nextPage = UIWindows.createImage("/img/newui/haoyoufyan_1.gnp");
		xiaoBackground = UIWindows.createImage("/img/newui/beibaobj_1.gnp");
		titleImg = UIWindows.createImage("/img/newui/jiazu_1.gnp");
		
		m_family_ditu = UIWindows.createImage("/img/newui/chengjiubj_1.gnp");
		m_right_button01 = UIWindows.createImage("/img/newui/anniu_2.gnp");
		m_right_button02 = UIWindows.createImage("/img/newui/anniu_2ax.gnp");
		m_left_button01 = UIWindows.createImage("/img/newui/anniu_17.gnp");
		m_left_button02 = UIWindows.createImage("/img/newui/anniu_17ax.gnp");
		m_bm_backGround = UIWindows.createImage("/img/newui/beibaobj_2.gnp");
		
		Animation renwu1 = UIWindows.createAnimation("/anim/jinbi_1.anim");
		m_gongxian_actor[0] = new Actor(renwu1);
		Animation renwu2 = UIWindows.createAnimation("/anim/yuanbao_1.anim");
		m_gongxian_actor[1] = new Actor(renwu2);
		Animation renwu3 = UIWindows.createAnimation("/anim/yuanbao_2.anim");
		m_gongxian_actor[2] = new Actor(renwu3);
		
		Animation left = UIWindows.createAnimation("/anim/anniu_17.anim");
		m_list_actot = new Actor(left);//捐献
		
		m_list_button01 = UIWindows.createImage("/img/newui/anniu_16.gnp");
		m_list_button02 = UIWindows.createImage("/img/newui/anniu_16ax.gnp");
		
		m_left_image = UIWindows.createImage("/img/newui/jiaoyimingzibeijing.gnp");
	}

	private int m_state;

	public void open(byte index)
	{
		m_state = index;
		m_dismiss_star_time = 0;
		m_dismiss_time = 0;
		dissmiss_time = 0;
		initDate();
		if (DWGameManager.getInstance().m_role != null)
		{
			DWGameManager.getInstance().getSendMessage().sendFamilyOwnMessage(); //查看自己家族详细信息
		}
	}

	private void initDate()
	{
		m_family_name = null;//家族名称
		m_family_apply_list = null;//家族申请列表(包含申请合并家族)
		m_family_member_list = null;//家族成员列表
		m_family_message = null;//家族信息数组

		m_family_content = null;//临时的家族公告 宣言

		m_family_apply_page = 0;//家族申请列表当前页 从1开始
		m_family_apply_amount = 0;//家族申请列表总页数

		m_family_member_page = 0;//家族成员列表当前页 从1开始
		m_family_member_amount = 0;//家族成员列表总页数
	}

	public void close(byte index)
	{
		selectID = -1;
		m_family_supList = null;
		m_frame_isFirst = true;
		netlock = 0;
		DWControlsManager.getInstance().removeControl(m_family_Frame);
		m_family_Frame = null;
		luckyStop();
	}

	public void dispose()
	{
	}

	private DWFrame m_dismiss_frame;
	private DWTextbox m_dismiss_messageBox;
	private DWImageBox m_dismiss_close;
	private DWButton m_dismiss_cancel;
	private DWPercentBar m_dismiss_bar;

	private void addFamilyDismiss()
	{
		m_dismiss_frame = new DWFrame(DWFrame.FRAME_TYPE_FULL);
//		m_dismiss_frame.addControl(m_family_windowBackground);
		m_family_Title = new DWTitle("家族", m_dismiss_frame);
		m_family_Title.setBackground(titleImg, false);
		m_dismiss_frame.addControl(m_family_Title);

		m_dismiss_close = new DWImageBox(closeWimdow);
		m_dismiss_close.setTouchZoomIn(UIFixWindow.TOUCHZOOM, UIFixWindow.TOUCHZOOM);
		m_dismiss_close.setNearAnchor(m_family_Title, Tools.RIGHT_TOP, Tools.RIGHT_TOP);
		m_dismiss_close.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_dismiss_frame);
				close((byte) 0);
			}
		});
		m_dismiss_frame.addControl(m_dismiss_close);

		m_family_windowBackground = new DWBackground(m_dismiss_frame.getShowWidth() - 40,
				m_dismiss_frame.getShowHeight() - 80);
		m_family_windowBackground.setNearAnchor(m_dismiss_frame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -20);
		m_dismiss_frame.addControl(m_family_windowBackground);

		if (m_family_position == 2)
		{
			m_dismiss_messageBox = new DWTextbox("取消解散剩余时间");
			m_dismiss_messageBox.setNearAnchor(m_family_windowBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
			m_dismiss_frame.addControl(m_dismiss_messageBox);

			m_dismiss_bar = new DWPercentBar(m_family_windowBackground.getShowWidth() / 2, foregroundImg, backgroundImg);
			m_dismiss_bar.setPercent((int) m_family.m_dismiss_time, (int) m_family.m_dismiss_total_time);
			m_dismiss_bar.setNearAnchor(m_dismiss_messageBox, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 5);
			m_dismiss_frame.addControl(m_dismiss_bar);

//			m_dismiss_time_lable=new DWLabel(UIBag.getTime(m_family.m_dismiss_time));
//			m_dismiss_time_lable.setNearAnchor(m_dismiss_bar, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
//			m_dismiss_time_lable.setBackgroundColor(Tools.ALPHA);
//			m_dismiss_frame.addControl(m_dismiss_time_lable);

			m_dismiss_cancel = new DWButton("取消解散", buttonImg);
			m_dismiss_cancel.setDownImage(anxiabutonImg);
			m_dismiss_cancel.setNearAnchor(m_dismiss_bar, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 10);
			m_dismiss_cancel.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWGameManager.getInstance().showToast("发送取消解散家族请求……", Toast.LENGTH_SHORT);
					DWGameManager.getInstance().getSendMessage().sendFamilyCancelDismiss();
				}
			});
			m_dismiss_frame.addControl(m_dismiss_cancel);
		}
		else
		{
			m_dismiss_messageBox = new DWTextbox("家族解散中……");
			m_dismiss_messageBox.setNearAnchor(m_family_windowBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
			m_dismiss_frame.addControl(m_dismiss_messageBox);

			m_dismiss_bar = new DWPercentBar(m_family_windowBackground.getShowWidth() / 2, foregroundImg, backgroundImg);
			m_dismiss_bar.setPercent((int) m_family.m_dismiss_time, (int) m_family.m_dismiss_total_time);
			m_dismiss_bar.setNearAnchor(m_dismiss_messageBox, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 5);
			m_dismiss_frame.addControl(m_dismiss_bar);
		}

		DWControlsManager.getInstance().addControl(m_dismiss_frame);
	}

	private void addFamily()
	{
		m_family_Frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER);
		m_family_Title = new DWTitle("家族", m_family_Frame);
		m_family_Frame.addControl(m_family_Title);

		DWLabel addFamilyLable = new DWLabel("加入家族名称  ");
		addFamilyLable.setNearAnchor(m_family_Frame, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, (m_family_Frame
				.getShowWidth() / 2 - addFamilyLable.getShowWidth()) / 2, -(m_family_Frame.getShowHeight() / 10));
		m_family_Frame.addControl(addFamilyLable);

		final DWInputBox famliyName = new DWInputBox(m_family_Frame.getShowWidth() / 2, 40, m_family_Frame);
		famliyName.setNearAnchor(addFamilyLable, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);
		m_family_Frame.addControl(famliyName);

		DWButton familyPaiHang = new DWButton("家族列表", buttonImg);
		familyPaiHang.setDownImage(anxiabutonImg);
		familyPaiHang.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_family_Frame);
				openFamilyList();
			}
		});
		familyPaiHang.setNearAnchor(m_family_Frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, m_family_Frame
				.getShowHeight() / 10);
		m_family_Frame.addControl(familyPaiHang);

		DWButton familyCreat = new DWButton("创建家族", buttonImg);
		familyCreat.setDownImage(anxiabutonImg);
		familyCreat.setNearAnchor(familyPaiHang, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 30);
		m_family_Frame.addControl(familyCreat);
		familyCreat.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				final DWFrame creat_family_Frame = new DWFrame(450, 250);
				creat_family_Frame.setClickClose(false);

				DWLabel creat_family_label = new DWLabel("创建家族名称  ");
				creat_family_label.setBackgroundColor(Tools.ALPHA);
				final DWInputBox creat_family_inputBox = new DWInputBox(200, 40, creat_family_Frame);
				creat_family_label.setNearAnchor(creat_family_Frame, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER,
						(250 - creat_family_label.getShowWidth()) / 2, 0);
				creat_family_inputBox.setNearAnchor(creat_family_label, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);

				creat_family_Frame.addControl(creat_family_label);
				creat_family_Frame.addControl(creat_family_inputBox);

				DWButton creat_family_button1 = new DWButton("创建", buttonImg);
				creat_family_button1.setDownImage(anxiabutonImg);
				creat_family_button1.setNearAnchor(creat_family_Frame, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 5, -5);
				creat_family_button1.addListener(new DWListener() {
					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						String msg = creat_family_inputBox.getText();
						if (msg == null || msg.equals(""))
						{
							DWGameManager.getInstance().showToast("家族名称不能为空", Toast.LENGTH_SHORT);
						}
						else if (msg.length() < 2)
						{
							DWGameManager.getInstance().showToast("用户名过短!", Toast.LENGTH_SHORT);
						}
						else if (msg.length() > 6)
						{
							DWGameManager.getInstance().showToast("用户名过长!", Toast.LENGTH_SHORT);
						}
						else
						{
							DWGameManager.getInstance().showToast("发送创建家族请求……", Toast.LENGTH_SHORT);
							m_family_name = msg;
							DWControlsManager.getInstance().removeControl(creat_family_Frame);
							DWGameManager.getInstance().getSendMessage().sendFamilyCreate(msg);
						}
					}
				});
				DWButton creat_family_button2 = new DWButton("取消", buttonImg);
				creat_family_button2.setDownImage(anxiabutonImg);
				creat_family_button2.setNearAnchor(creat_family_Frame, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -5, -5);
				creat_family_button2.addListener(new DWListener() {
					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						DWControlsManager.getInstance().addControl(m_family_Frame);
						DWControlsManager.getInstance().removeControl(creat_family_Frame);
					}
				});

				creat_family_Frame.addControl(creat_family_button1);
				creat_family_Frame.addControl(creat_family_button2);

				DWControlsManager.getInstance().removeControl(m_family_Frame);
				DWControlsManager.getInstance().addControl(creat_family_Frame);
			}
		});

		DWButton Cancer = new DWButton("确定", buttonImg);
		Cancer.setDownImage(anxiabutonImg);
		Cancer.setNearAnchor(m_family_Frame, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 10, -10);
		m_family_Frame.addControl(Cancer);
		Cancer.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_family_Frame);
				String familyText = famliyName.getText();
				if (familyText == null || familyText.equals(""))
				{
					DWGameManager.getInstance().showToast("家族名称不能为空", Toast.LENGTH_SHORT);
				}
				else
				{
					DWGameManager.getInstance().showToast("发送加入家族请求，请等待回复……", Toast.LENGTH_SHORT);
					DWGameManager.getInstance().getSendMessage().sendFamilyApplyAddName(familyText);
				}
			}
		});

		DWButton Back = new DWButton("返回", buttonImg);
		Back.setDownImage(anxiabutonImg);
		Back.setNearAnchor(m_family_Frame, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -10, -10);
		m_family_Frame.addControl(Back);
		Back.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				close((byte) 0);
			}
		});

		DWControlsManager.getInstance().addControl(m_family_Frame);
	}

	private void initFrame()
	{
		if (DWControlsManager.getInstance().contains(m_family_Frame))
		{
			DWControlsManager.getInstance().removeControl(m_family_Frame);
			m_family_Frame = null;
		}
		m_family_Frame = new DWFrame(DWFrame.FRAME_TYPE_FULL);
		m_family_Frame.setClickClose(false);
		m_family_Title = new DWTitle("家族", m_family_Frame);
		m_family_Title.setBackground(titleImg, false);
		m_family_Frame.addControl(m_family_Title);

		m_family_Close = new DWImageBox(closeWimdow);
		m_family_Close.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				close((byte) 0);
			}
		});
		m_family_Close.setTouchZoomIn(UIFixWindow.TOUCHZOOM, UIFixWindow.TOUCHZOOM);
		m_family_Close.setNearAnchor(m_family_Title, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER);
		m_family_Frame.addControl(m_family_Close);

		m_family_windowBackground = new DWBackground(m_family_Frame.getShowWidth() - 40,
				m_family_Frame.getShowHeight() - tabSelectImg.getHeight() - 50);
		m_family_windowBackground.setNearAnchor(m_family_Frame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -20);
		m_family_Frame.addControl(m_family_windowBackground);

		m_family_TabControl = new DWTabControl(tabUnSelectImg, tabSelectImg,
				m_family_windowBackground.getShowWidth() - 20, m_family_windowBackground.getShowHeight() + 30);
		m_family_TabControl.setNearAnchor(m_family_windowBackground, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0,
				-tabUnSelectImg.getHeight());
		m_family_TabControl.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_family_TabControl.getPageIndex() == QIFU)
				{
					DWControlsManager.getInstance().removeControl(m_family_Frame);
					qifuFrame();
				}else if(m_family_TabControl.getPageIndex() == JINENG){
					if(m_isFirstOpenSkill){
						m_isFirstOpenSkill =false;
						DWGameManager.getInstance().getSendMessage().sendFamilLookSkill();
					}else{
						DWGameManager.getInstance().getSendMessage().sendFamilLookSkillAgain();
					}

				}
			}
		});
		m_family_Frame.addControl(m_family_TabControl);

		for (int i = 0; i < m_tabName.length; i++)
		{
			m_family_pages[i] = new DWTabPage();
			m_family_pages[i].setName(m_tabName[i]);
			switch (i) {
				case 0:
					addPage0();
					break;
//				case 1:
//					familySkill();
//					break;
				case 2:
					addPage1();
					break;
				case 3:
					addPage2();
					break;
					
			}
		}
		m_family_TabControl.addTabPages(m_family_pages);
	}

	private short listboxMax = 0;
	private DWTextbox m_family_MessageBox;
	private DWListbox m_family_Listbox;
	private DWBackground m_family_listTitle;
	private DWLabel[] m_family_listLable = new DWLabel[4];
//	private DWTextbox m_family_ListTextbbox[] = new DWTextbox[listboxMax];
	private DWBackground m_famliy_leftBackground;
	private DWBackground m_family_rightBackground;
	private DWButton m_family_notice;//家族公告
	private DWButton m_family_manifesto;//家族宣言
	private DWImageBox m_family_brforePage;
	private DWImageBox m_family_nextPage;
	private DWTextbox m_family_pageNum;
	private String[] family_listTitle_str = { "姓名", "等级", "贡献", "职位" };
	private int moveX;

	private void addPage0()
	{
		m_famliy_leftBackground = new DWBackground(xiaoBackground, m_family_TabControl.getShowWidth() / 2 - 15,
				m_family_TabControl.getShowHeight() - tabSelectImg.getHeight() - 20);
		m_famliy_leftBackground.setFill(false);
		m_famliy_leftBackground.setNearAnchor(m_family_pages[CHENGYUAN], Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10);
		m_family_pages[CHENGYUAN].addControls(m_famliy_leftBackground);

		m_family_MessageBox = new DWTextbox("     ", m_famliy_leftBackground.getShowWidth() - 20,
				m_famliy_leftBackground.getShowHeight() - 15 - buttonImg.getHeight());
		m_family_MessageBox.setNearAnchor(m_famliy_leftBackground, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 5);
		m_family_pages[CHENGYUAN].addControls(m_family_MessageBox);

		m_family_rightBackground = new DWBackground(xiaoBackground, m_famliy_leftBackground.getShowWidth(),
				m_famliy_leftBackground.getShowHeight());
		m_family_rightBackground.setNearAnchor(m_family_pages[CHENGYUAN], Tools.RIGHT_TOP, Tools.RIGHT_TOP, -10, 10);
		m_family_pages[CHENGYUAN].addControls(m_family_rightBackground);

		if (m_family_position == GUANLI)
		{
			m_family_notice = new DWButton("修改公告", buttonImg);
			m_family_notice.setDownImage(anxiabutonImg);
			m_family_notice.setNearAnchor(m_family_MessageBox, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 40, 5);
			m_family_notice.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					final DWFrame creat_family_Frame = new DWFrame(450, 250);
					DWTextbox creat_family_label = new DWTextbox("家族公告 `<mark c=55FF00>0-30之间</mark>", 100,
							creat_family_Frame.getShowHeight() - buttonImg.getHeight() - 20);
					final DWInputBox creat_family_inputBox = new DWInputBox(300, 180, creat_family_Frame);
					creat_family_label.setNearAnchor(creat_family_Frame, Tools.LEFT_TOP, Tools.LEFT_TOP,
							(450 - creat_family_label.getShowWidth() - creat_family_inputBox.getShowWidth()) / 2, 10);
					creat_family_inputBox.setNearAnchor(creat_family_label, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);
					creat_family_inputBox.addListener(new DWListener() {

						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							inputListen(creat_family_inputBox);
						}
					});
					creat_family_Frame.addControl(creat_family_label);
					creat_family_Frame.addControl(creat_family_inputBox);

					DWButton creat_family_button1 = new DWButton("修改", buttonImg);
					creat_family_button1.setDownImage(anxiabutonImg);
					creat_family_button1.setNearAnchor(creat_family_Frame, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 5, -5);
					creat_family_button1.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							String msg = creat_family_inputBox.getText();
							if (msg == null || msg.equals(""))
							{
								DWGameManager.getInstance().showToast("家族家族公告不能为空", Toast.LENGTH_SHORT);
							}
							else if (msg.length() < 2)
							{
								DWGameManager.getInstance().showToast("家族公告过短!", Toast.LENGTH_SHORT);
							}
							else
							{
								DWGameManager.getInstance().showToast("发送修改家族公告请求……", Toast.LENGTH_SHORT);
								DWControlsManager.getInstance().removeControl(creat_family_Frame);
								m_family_content = msg;
								DWGameManager.getInstance().getSendMessage().sendFamilyModifyNotice(msg);
							}
						}
					});
					DWButton creat_family_button2 = new DWButton("取消", buttonImg);
					creat_family_button2.setDownImage(anxiabutonImg);
					creat_family_button2.setNearAnchor(creat_family_Frame, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -5,
							-5);
					creat_family_button2.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							DWControlsManager.getInstance().removeControl(creat_family_Frame);
						}
					});

					creat_family_Frame.addControl(creat_family_button1);
					creat_family_Frame.addControl(creat_family_button2);

					DWControlsManager.getInstance().addControl(creat_family_Frame);
				}
			});

			m_family_pages[CHENGYUAN].addControls(m_family_notice);

			m_family_manifesto = new DWButton("修改宣言", buttonImg);
			m_family_manifesto.setDownImage(anxiabutonImg);
			m_family_manifesto.setNearAnchor(m_family_MessageBox, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, -40, 5);
			m_family_manifesto.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					final DWFrame creat_family_Frame = new DWFrame(450, 250);
					DWTextbox creat_family_label = new DWTextbox("家族宣言 `<mark c=55FF00>0-30之间</mark>", 100,
							creat_family_Frame.getShowHeight() - buttonImg.getHeight() - 20);
					final DWInputBox creat_family_inputBox = new DWInputBox(300, 180, creat_family_Frame);
					creat_family_label.setNearAnchor(creat_family_Frame, Tools.LEFT_TOP, Tools.LEFT_TOP,
							(450 - creat_family_label.getShowWidth() - creat_family_inputBox.getShowWidth()) / 2, 10);
					creat_family_inputBox.setNearAnchor(creat_family_label, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);
					creat_family_inputBox.addListener(new DWListener() {

						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							inputListen(creat_family_inputBox);
						}
					});

					creat_family_Frame.addControl(creat_family_label);
					creat_family_Frame.addControl(creat_family_inputBox);

					DWButton creat_family_button1 = new DWButton("修改", buttonImg);
					creat_family_button1.setDownImage(anxiabutonImg);
					creat_family_button1.setNearAnchor(creat_family_Frame, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 5, -5);
					creat_family_button1.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							String msg = creat_family_inputBox.getText();
							if (msg == null || msg.equals(""))
							{
								DWGameManager.getInstance().showToast("家族宣言不能为空", Toast.LENGTH_SHORT);
							}
							else if (msg.length() < 2)
							{
								DWGameManager.getInstance().showToast("家族宣言过短!", Toast.LENGTH_SHORT);
							}
							else
							{
								DWGameManager.getInstance().showToast("发送修改家族宣言请求……", Toast.LENGTH_SHORT);
								DWControlsManager.getInstance().removeControl(creat_family_Frame);
								m_family_content = msg;
								DWGameManager.getInstance().getSendMessage().sendFamilyModifyManifesto(msg);
							}
						}
					});
					DWButton creat_family_button2 = new DWButton("取消", buttonImg);
					creat_family_button2.setDownImage(anxiabutonImg);
					creat_family_button2.setNearAnchor(creat_family_Frame, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -5,
							-5);
					creat_family_button2.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							DWControlsManager.getInstance().removeControl(creat_family_Frame);
						}
					});

					creat_family_Frame.addControl(creat_family_button1);
					creat_family_Frame.addControl(creat_family_button2);

					DWControlsManager.getInstance().addControl(creat_family_Frame);
				}
			});
			m_family_pages[CHENGYUAN].addControls(m_family_manifesto);
		}

		m_family_listTitle = new DWBackground(listTitle, m_family_rightBackground.getShowWidth() - 10, 30);
		m_family_listTitle.setNearAnchor(m_family_rightBackground, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 10);
		m_family_pages[CHENGYUAN].addControls(m_family_listTitle);

		moveX = m_family_listTitle.getShowWidth() / (family_listTitle_str.length + 1);
		for (int i = 0; i < family_listTitle_str.length; i++)
		{
			m_family_listLable[i] = new DWLabel(family_listTitle_str[i]);
			m_family_listLable[i].setBackgroundColor(Tools.ALPHA);
			m_family_listLable[i].setNearAnchor(m_family_listTitle, Tools.HCENTER_VCENTER, Tools.LEFT_VCENTER, moveX
					* (i + 1), 0);
			m_family_pages[CHENGYUAN].addControls(m_family_listLable[i]);
		}

		m_family_pageNum = new DWTextbox("  0/0  ");
		m_family_pageNum.setNearAnchor(m_family_rightBackground, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -5);
		m_family_pages[CHENGYUAN].addControls(m_family_pageNum);

		m_family_brforePage = new DWImageBox(beforePage);
		m_family_brforePage.setNearAnchor(m_family_pageNum, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, -10, 0);
		m_family_brforePage.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_family_member_page == 0)
				{
					DWGameManager.getInstance().showToast("这已经是第一页了", Toast.LENGTH_SHORT);
				}
				else
				{
					DWGameManager.getInstance().getSendMessage().sendFamilyMemberList(
							(short) (m_family_member_page - 1),
							listboxMax);
					DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
				}
			}
		});
		m_family_pages[CHENGYUAN].addControls(m_family_brforePage);

		m_family_nextPage = new DWImageBox(nextPage);
		m_family_nextPage.setNearAnchor(m_family_pageNum, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
		m_family_nextPage.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_family_member_page < (m_family_member_amount - 1))
				{
					DWGameManager.getInstance().getSendMessage().sendFamilyMemberList(
							(short) (m_family_member_page + 1),
							listboxMax);
					DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
				}
				else
				{
					DWGameManager.getInstance().showToast("这已经是最后一页了", Toast.LENGTH_SHORT);
				}
			}
		});
		m_family_pages[CHENGYUAN].addControls(m_family_nextPage);

		m_family_Listbox = new DWListbox(m_family_MessageBox.getShowWidth(), m_family_MessageBox.getShowHeight()
				- m_family_listTitle.getShowHeight() - 10 - m_family_pageNum.getShowHeight());
		m_family_Listbox.setNearAnchor(m_family_listTitle, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 5);
		m_family_pages[CHENGYUAN].addControls(m_family_Listbox);

		/////为计算有多少行无实际显示用途
		if (listboxMax <= 0)
		{
			DWTextbox text = new DWTextbox("  ");

			listboxMax = (short) (m_family_Listbox.getShowHeight() / text.getShowHeight());
			Tools.debugPrintln("listboxMax-----------------------》" + listboxMax);
		}

		m_family_Listbox.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_family_member_list[m_family_Listbox.getTouchIndex()] != null)
				{
					if (m_family_member_list[m_family_Listbox.getTouchIndex()].m_gameID == DWGameManager.getInstance().m_role.m_gameId)
					{
						DWGameManager.getInstance().showToast("这是你自己！", Toast.LENGTH_SHORT);
					}
					else {
						int num = 0;
						if (m_family_position == GUANLI)
						{
							if (m_family_member_list[m_family_Listbox.getTouchIndex()].m_position == 1)
								num = 1;
							else if (m_family_member_list[m_family_Listbox.getTouchIndex()].m_position == 2)
								num = 2;
						}

						final String[] popMenu = FAMILY_MEMBER_MENU[num];
						final DWPopMenu itemMenu = new DWPopMenu(popMenu, popMenuImg);
						itemMenu.setDownImage(popAnxiaMenuImg);

						itemMenu.addListener(new DWListener() {

							public void OnDoubleClick()
							{
							}

							public void OnClick()
							{
								m_family_Frame.removeControl(itemMenu);
								ItemKeyListener(itemMenu.getIndex(), popMenu);
							}
						});

						m_family_Frame.addControl(itemMenu);
					}
				}
			}
		});

	}

	/**
	 * 输入字数限制
	 * @param input
	 */
	private void inputListen(DWInputBox input)
	{
		String input_str = input.getText();
		if (input_str.length() > 30)
		{
			input_str = input_str.substring(0, 30);
			input.setText(input_str);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "输入字符超过30了！");
		}
	}

	/**
	 * 成员列表监听
	 * @param buttonID
	 * @param buttonMenu
	 */
	private void ItemKeyListener(int buttonID, String[] buttonMenu)
	{
		int roleIndex = m_family_Listbox.getTouchIndex();
		final long memberID = m_family_member_list[roleIndex].m_gameID;

		if (buttonMenu[buttonID].equals("查看信息"))
		{
			Tools.debugPrintln("gameid" + m_family_member_list[roleIndex].m_gameID);
			DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(m_family_member_list[roleIndex].m_gameID);
		}
		else if (buttonMenu[buttonID].equals("发送信件"))
		{
			DWControlsManager.getInstance().removeControl(m_family_Frame);
			UIWindows.getInstance().m_mail.open((byte) 0);
			UIWindows.getInstance().m_mail.m_tabcontrol.setSelectPage(1);
			UIWindows.getInstance().m_mail.m_send_recv_ib.setText(m_family_member_list[roleIndex].m_name);
		}
		else if (buttonMenu[buttonID].equals("开除成员"))
		{
			Tools.debugPrintln("开除成员");
			final DWMessageBox msg = new DWMessageBox("提示", "确定要开除成员？");
			msg.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(msg);
					if (msg.getResult() == DWMessageBox.SOFTKEY_OK)
					{
						DWGameManager.getInstance().getSendMessage().sendFamilyExpel(memberID);
					}
				}
			});
			DWControlsManager.getInstance().addControl(msg);

		}
		else if (buttonMenu[buttonID].equals("禅让族长"))
		{
			Tools.debugPrintln("禅让族长");
			final DWMessageBox msg = new DWMessageBox("提示", "确定要禅让族长？");
			msg.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(msg);
					if (msg.getResult() == DWMessageBox.SOFTKEY_OK)
					{
						DWGameManager.getInstance().getSendMessage().sendFamilyDemiseSheikh(memberID);
					}
				}
			});
			DWControlsManager.getInstance().addControl(msg);

		}
		else if (buttonMenu[buttonID].equals("提拔长老"))
		{
			Tools.debugPrintln("提拔长老");
			final DWMessageBox msg = new DWMessageBox("提示", "确定要提拔长老？");
			msg.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(msg);
					if (msg.getResult() == DWMessageBox.SOFTKEY_OK)
					{
						DWGameManager.getInstance().getSendMessage().sendFamilySetElder(FAMILY_SETELDER_PROMOTION,
								memberID);
					}
				}
			});
			DWControlsManager.getInstance().addControl(msg);
		}
		else if (buttonMenu[buttonID].equals("免职长老"))
		{
			Tools.debugPrintln("免职长老");
			final DWMessageBox msg = new DWMessageBox("提示", "确定要免职长老？");
			msg.addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(msg);
					if (msg.getResult() == DWMessageBox.SOFTKEY_OK)
					{
						DWGameManager.getInstance().getSendMessage().sendFamilySetElder(FAMILY_SETELDER_DEPOSE,
								memberID);
					}
				}
			});
			DWControlsManager.getInstance().addControl(msg);
		}
	}

	private DWTextbox m_family_lv1;
	private DWTextbox m_family_lv2;
	private DWBackground m_family_lvleftBackground;
	private DWBackground m_family_lvrightBackground;
	private DWBackground m_family_lvBackground;
	private DWImageBox m_family_nextlv;

//	private String m_family_lvTips = "家族成员完成任务，参与竞技场或副本活动可以提升家族等级";

	private void addPage1()
	{
		m_family_lvleftBackground = new DWBackground(xiaoBackground, m_family_TabControl.getShowWidth() / 2 - 15,
				m_family_TabControl.getShowHeight() - tabSelectImg.getHeight() - 20 - 30);
		m_family_lvleftBackground.setNearAnchor(m_family_pages[DENGJI], Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10);
		m_family_pages[DENGJI].addControls(m_family_lvleftBackground);

		m_family_lvrightBackground = new DWBackground(xiaoBackground, m_family_lvleftBackground.getShowWidth(),
				m_family_lvleftBackground.getShowHeight());
		m_family_lvrightBackground.setNearAnchor(m_family_pages[DENGJI], Tools.RIGHT_TOP, Tools.RIGHT_TOP, -10, 10);
		m_family_pages[DENGJI].addControls(m_family_lvrightBackground);

		m_family_lv1 = new DWTextbox("   ", m_family_lvleftBackground.getShowWidth() - 20, m_family_lvleftBackground
				.getShowHeight() - 20);
		m_family_lv1.setNearAnchor(m_family_lvleftBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_family_pages[DENGJI].addControls(m_family_lv1);

		m_family_lv2 = new DWTextbox("   ", m_family_lvrightBackground.getShowWidth() - 20, m_family_lvrightBackground
				.getShowHeight() - 20);
		m_family_lv2.setNearAnchor(m_family_lvrightBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_family_pages[DENGJI].addControls(m_family_lv2);

		m_family_lvBackground = new DWBackground(messageBackground, m_family_TabControl.getShowWidth() - 20, 30);
		m_family_lvBackground.setNearAnchor(m_family_pages[DENGJI], Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);
		m_family_pages[DENGJI].addControls(m_family_lvBackground);

		DWTextbox lvTips = new DWTextbox(m_family_supTips);
		lvTips.setNearAnchor(m_family_lvBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_family_pages[DENGJI].addControls(lvTips);

		m_family_nextlv = new DWImageBox(nextlv);
		m_family_nextlv.setNearAnchor(m_family_lvleftBackground, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 20, -20);
		m_family_pages[DENGJI].addControls(m_family_nextlv);
	}

	private DWButton[] m_family_button = new DWButton[6];
	private DWBackground m_family_buttonBackground;
	private DWBackground m_family_superviseBackground;
	private DWBackground m_family_tipsBackground;
	private short supMaxList = 0;
	private String m_family_supTips = "<mark c=FFBB11>家族成员完成任务，参与竞技场或副本活动可以提升家族等级</mark>";
	private String[] m_family_buttonStr;
	private int selectID = -1;

	private void addPage2()
	{
		Tools.debugPrintln("职位：" + m_family_position);
		m_family_buttonStr = FAMILY_MANAGE_MENU[m_family_position];

		m_family_superviseBackground = new DWBackground(xiaoBackground, m_family_lvleftBackground.getShowWidth(),
				m_family_lvleftBackground
						.getShowHeight());
		m_family_superviseBackground.setNearAnchor(m_family_pages[GUANLI], Tools.RIGHT_TOP, Tools.RIGHT_TOP, -10, 10);
		m_family_pages[GUANLI].addControls(m_family_superviseBackground);

		m_family_buttonBackground = new DWBackground(xiaoBackground, m_family_lvleftBackground.getShowWidth(),
				m_family_lvleftBackground
						.getShowHeight());
		m_family_buttonBackground.setNearAnchor(m_family_pages[GUANLI], Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10);
		m_family_pages[GUANLI].addControls(m_family_buttonBackground);

		addRight(0);
		selectID = 0;

		int moveX = (m_family_buttonBackground.getShowWidth() - buttonImg.getWidth() * 2) / 3;
		int movey = (m_family_buttonBackground.getShowHeight() - buttonImg.getHeight()
				* ((m_family_buttonStr.length + 1) / 2))
				/ (((m_family_buttonStr.length + 1) / 2) + 1);
		for (int i = 0; i < m_family_buttonStr.length; i++)
		{
			final int type = i;
			m_family_button[i] = new DWButton(m_family_buttonStr[i], buttonImg);
			m_family_button[i].setDownImage(anxiabutonImg);
			m_family_button[i].setNearAnchor(m_family_pages[GUANLI], Tools.LEFT_TOP, Tools.LEFT_TOP, moveX + (i % 2)
					* (buttonImg.getWidth() + moveX), (i / 2 + 1) * movey + i / 2 * buttonImg.getHeight());
			m_family_pages[GUANLI].addControls(m_family_button[i]);

			m_family_button[i].addListener(new DWListener() {

				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					ButtonListener(type, m_family_buttonStr);
				}
			});
		}

		m_family_tipsBackground = new DWBackground(messageBackground, m_family_TabControl.getShowWidth() - 20, 30);
		m_family_tipsBackground.setNearAnchor(m_family_pages[GUANLI], Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);
		m_family_pages[GUANLI].addControls(m_family_tipsBackground);

		DWTextbox supTips = new DWTextbox(m_family_supTips);
		supTips.setNearAnchor(m_family_tipsBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_family_pages[GUANLI].addControls(supTips);
	}

	/**
	 * 按钮组监听
	 * @param buttonID 按钮索引
	 * @param buttonMenu 按钮文本数组
	 */
	private void ButtonListener(int buttonID, String[] buttonMenu)
	{
//		if (buttonMenu[buttonID].equals("兑换帮贡"))
//		{
//			DWGameManager.getInstance().getSendMessage().sendHelpCount();
//		}
//		else
		if(buttonMenu[buttonID].equals("捐献帮贡")){
			listFrame();
		}
		else if (buttonMenu[buttonID].equals("家贡商店"))
		{
			DWGameManager.getInstance().getSendMessage().sendFunction(13000, "jiagongshangdian");
		}
		else if (buttonMenu[buttonID].equals("邀请入族"))
		{
			addRight(1);
			selectID = 1;
		}
		else if (buttonMenu[buttonID].equals("家族合并"))
		{
			addRight(2);
			selectID = 2;
		}
		else
		{
			if (selectID != 0)
			{
				addRight(0);
				selectID = 0;
			}

			if (buttonMenu[buttonID].equals("家族解散"))
			{
				Tools.debugPrintln("家族解散");
				final DWMessageBox msg = new DWMessageBox("提示", "确定要解散家族？");
				msg.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						DWControlsManager.getInstance().removeControl(msg);
						if (msg.getResult() == DWMessageBox.SOFTKEY_OK)
						{
							DWGameManager.getInstance().getSendMessage().sendFamilyDismiss();
						}
					}
				});
				DWControlsManager.getInstance().addControl(msg);

			}
			else if (buttonMenu[buttonID].equals("参与祈福"))
			{
				DWControlsManager.getInstance().removeControl(m_family_Frame);
				qifuFrame();
				Tools.debugPrintln("参与祈福");
			}
			else if (buttonMenu[buttonID].equals("退出家族"))
			{
				Tools.debugPrintln("退出家族");

				final DWMessageBox msg = new DWMessageBox("提示", "退出家族后，24小时内不可再次加入其他家族或建立新家族，是否继续？");
				msg.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						DWControlsManager.getInstance().removeControl(msg);
						if (msg.getResult() == DWMessageBox.SOFTKEY_OK)
						{
							DWGameManager.getInstance().getSendMessage().sendFamilyConfirmLeave();
						}
					}
				});
				DWControlsManager.getInstance().addControl(msg);

			}
		}
	}

//	private boolean isOK;
//	private void showMessageBox(final String text,final int type)
//	{
//         isOK=false;
//		final DWMessageBox msg=new DWMessageBox("提示", text);
//		msg.addListener(new DWListener() {
//			
//			public void OnDoubleClick()
//			{
//			}
//			
//			public void OnClick()
//			{
//				DWControlsManager.getInstance().removeControl(msg);
//				if(msg.getResult()==DWMessageBox.SOFTKEY_OK)
//				{
//			         isOK=true;
//				}						
//			}
//		});
//		DWControlsManager.getInstance().addControl(msg);
//	}

	private DWListbox m_family_supList;
	private DWTextbox[] m_family_supTextbox;
	private DWTextbox m_family_supPageNum;
	private DWImageBox m_family_supBeforPage;
	private DWImageBox m_family_supNextPage;
	
	private DWTextbox m_shenqing_tishi = null;

	DWLabel supUsernameLb;
	DWInputBox supUsername;
	DWButton supAddUser;

	DWLabel familyNameLb;
	DWInputBox familyName;
	DWTextbox familyRule;
	DWButton hebing;

	private final String m_family_rule = "家族合并规则：`1.邀请家族的等级及成员数量不大于等于被邀请家族。`2.邀请家族与被邀请家族的人员数量不可超过合并后家族的人口上限。`3.合并后被邀请家族将消失，请慎重决定。";

	/**
	 * 添加第三页右边的界面
	 * @param type
	 */
	private void addRight(int type)
	{
		if (type != selectID)
		{
			if (selectID != -1)
				removeRight();

			switch (type) {
				case 0:
					if (m_family_supList == null)
					{
						m_family_supPageNum = new DWTextbox("  0/0  ");
						m_family_supPageNum.setNearAnchor(m_family_superviseBackground, Tools.HCENTER_BOTTOM,
								Tools.HCENTER_BOTTOM, 0, -5);

						m_family_supBeforPage = new DWImageBox(beforePage);
						m_family_supBeforPage.setNearAnchor(m_family_supPageNum, Tools.RIGHT_VCENTER,
								Tools.LEFT_VCENTER, -10, 0);
						m_family_supBeforPage.addListener(new DWListener() {

							public void OnDoubleClick()
							{
							}

							public void OnClick()
							{
								if (m_family_apply_page == 0)
								{
									DWGameManager.getInstance().showToast("这已经是第一页了", Toast.LENGTH_SHORT);
								}
								else
								{
									DWGameManager.getInstance().getSendMessage().sendFamilyApplyList(
											(short) (m_family_apply_page - 1),
											supMaxList);
									DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
								}
							}
						});

						m_family_supNextPage = new DWImageBox(nextPage);
						m_family_supNextPage.setNearAnchor(m_family_supPageNum, Tools.LEFT_VCENTER,
								Tools.RIGHT_VCENTER, 10, 0);
						m_family_supNextPage.addListener(new DWListener() {
							public void OnDoubleClick()
							{
							}

							public void OnClick()
							{

								if (m_family_apply_page < (m_family_apply_amount - 1))
								{
									DWGameManager.getInstance().getSendMessage().sendFamilyApplyList(
											(short) (m_family_member_page + 1),
											supMaxList);
									DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
								}
								else
								{
									DWGameManager.getInstance().showToast("这已经是最后一页了", Toast.LENGTH_SHORT);
								}
							}
						});
						m_shenqing_tishi = new DWTextbox("家族申请列表");
						m_shenqing_tishi.setNearAnchor(m_family_superviseBackground, Tools.HCENTER_TOP,
								Tools.HCENTER_TOP, 0, 10);
						
						m_family_supList = new DWListbox(m_family_superviseBackground.getShowWidth(),
								m_family_superviseBackground.getShowHeight() - 20 - m_family_supPageNum.getShowHeight()-m_shenqing_tishi.getShowHeight());
						m_family_supList.setNearAnchor(m_shenqing_tishi, Tools.HCENTER_TOP,
								Tools.HCENTER_BOTTOM, 0, 0);

						if (supMaxList <= 0)
						{
							DWTextbox text = new DWTextbox("  ");

							supMaxList = (short) (m_family_supList.getShowHeight() / text.getShowHeight());
							Tools.debugPrintln("supMaxList-----------------------》" + supMaxList);
						}

						m_family_supTextbox = new DWTextbox[supMaxList];
						for (int i = 0; i < supMaxList; i++)
						{
							DWListSubItem item = new DWListSubItem();
							m_family_supTextbox[i] = new DWTextbox("  ", m_family_supList.getShowWidth());
							m_family_supTextbox[i].setNearAnchor(item, Tools.LEFT_TOP, Tools.LEFT_TOP);
							item.addControls(m_family_supTextbox[i]);
							m_family_supList.addSubItem(item);
						}

						m_family_supList.addListener(new DWListener() {
							public void OnDoubleClick()
							{
							}

							public void OnClick()
							{
								if (m_family_position != 0)
								{
									if (m_family_apply_list[m_family_supList.getTouchIndex()] != null)
									{
										final DWPopMenu applyAdd = new DWPopMenu(FAMILY_LIST_MENU, popMenuImg);
										applyAdd.setDownImage(popAnxiaMenuImg);
										applyAdd.addListener(new DWListener() {
											public void OnDoubleClick()
											{
											}

											public void OnClick()
											{
												List list = m_family_apply_list[m_family_supList.getTouchIndex()];
												m_family_Frame.removeControl(applyAdd);
												switch (applyAdd.getIndex()) {

													case 0:
														DWGameManager.getInstance().getSendMessage()
																.sendFamilyRatifyAdd(
																		list.m_type, list.m_id, FAMILY_INVITEE_AGREE);
														break;
													case 1:
														DWGameManager.getInstance().getSendMessage()
																.sendFamilyRatifyAdd(
																		list.m_type, list.m_id, FAMILY_INVITEE_REFUSE);
														break;
												}
											}
										});

										m_family_Frame.addControl(applyAdd);
									}
								}
							}
						});
					}

					m_family_pages[GUANLI].addControls(m_shenqing_tishi);
					m_family_pages[GUANLI].addControls(m_family_supList);
					m_family_pages[GUANLI].addControls(m_family_supPageNum);
					m_family_pages[GUANLI].addControls(m_family_supBeforPage);
					m_family_pages[GUANLI].addControls(m_family_supNextPage);
					break;
				case 1:

					supUsernameLb = new DWLabel("玩家名称");
					supUsernameLb.setBackgroundColor(Tools.ALPHA);
					supUsername = new DWInputBox(m_family_superviseBackground.getShowWidth() / 2, supUsernameLb
							.getShowHeight() * 3 / 2, m_family_Frame);
					supAddUser = new DWButton("邀请入族", buttonImg);

					supUsernameLb.setNearAnchor(m_family_superviseBackground, Tools.LEFT_VCENTER,
							Tools.LEFT_VCENTER, 20, 10);
					supUsername.setNearAnchor(supUsernameLb, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
					supAddUser.setNearAnchor(m_family_superviseBackground, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM,
							-20, -20);
					supAddUser.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							String str = supUsername.getText();
							if (str == null || str.equals(""))
							{
								DWGameManager.getInstance().showToast("请输入玩家名称", Toast.LENGTH_SHORT);
							}
							else
							{
								DWGameManager.getInstance().getSendMessage().sendFamilyInviteAddName(str);
							}
						}
					});

					m_family_pages[GUANLI].addControls(supUsernameLb);
					m_family_pages[GUANLI].addControls(supUsername);
					m_family_pages[GUANLI].addControls(supAddUser);
					break;
				case 2:

					familyNameLb = new DWLabel("家族名称");
					familyNameLb.setBackgroundColor(Tools.ALPHA);
					familyName = new DWInputBox(m_family_superviseBackground.getShowWidth() / 2, familyNameLb
							.getShowHeight() * 3 / 2, m_family_Frame);

					familyRule = new DWTextbox(m_family_rule, m_family_superviseBackground.getShowWidth() - 30);
					hebing = new DWButton("合并家族", buttonImg);

					familyRule.setNearAnchor(m_family_superviseBackground, Tools.HCENTER_VCENTER,
							Tools.HCENTER_VCENTER, 0, 0);
					familyNameLb.setNearAnchor(m_family_superviseBackground, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 10);
					familyName.setNearAnchor(familyNameLb, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
					hebing.setNearAnchor(m_family_superviseBackground, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -20,
							-10);
					hebing.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							String str = familyName.getText();
							if (str == null || str.equals(""))
							{
								DWGameManager.getInstance().showToast("请输入家族名称", Toast.LENGTH_SHORT);
							}
							else
							{
								DWGameManager.getInstance().getSendMessage().sendFamilyApplyMerge(str);
								DWGameManager.getInstance().showToast("请求已发送", Toast.LENGTH_SHORT);
							}
						}
					});

					m_family_pages[GUANLI].addControls(familyNameLb);
					m_family_pages[GUANLI].addControls(familyName);
					m_family_pages[GUANLI].addControls(familyRule);
					m_family_pages[GUANLI].addControls(hebing);
					break;
			}
		}
	}

	/**
	 * 移除第三个界面右边的控件
	 */
	private void removeRight()
	{
		switch (selectID) {
			case 0:
				m_family_pages[GUANLI].removeControl(m_family_supList);
				m_family_pages[GUANLI].removeControl(m_family_supPageNum);
				m_family_pages[GUANLI].removeControl(m_family_supBeforPage);
				m_family_pages[GUANLI].removeControl(m_family_supNextPage);
				break;
			case 1:
				m_family_pages[GUANLI].removeControl(supUsernameLb);
				m_family_pages[GUANLI].removeControl(supUsername);
				m_family_pages[GUANLI].removeControl(supAddUser);
				break;
			case 2:
				m_family_pages[GUANLI].removeControl(familyNameLb);
				m_family_pages[GUANLI].removeControl(familyName);
				m_family_pages[GUANLI].removeControl(familyRule);
				m_family_pages[GUANLI].removeControl(hebing);
				break;
		}
	}

	/**
	 * 将对象信息转换为字符串
	 * @param obj 需要转换的字符创数组
	 * @return
	 */
	private String[] getSting(Object[] obj)
	{
		String[] msg = new String[obj.length];
		if (obj instanceof SimpleRole[]) //成员列表
		{
			SimpleRole[] role = (SimpleRole[]) obj;
			for (int i = 0; i < msg.length; i++) {
				if (obj[i] == null)
					break;
				msg[i] = "";
				msg[i] += role[i].m_name + "   ";
				msg[i] += role[i].m_grade + "   ";
				msg[i] += Role.ROLE_VOCATION_LIST[role[i].m_vocation + 1] + "   ";
				msg[i] += FAMILY_POSITION[role[i].m_position - 1];
			}
		}
		else if (obj instanceof List[]) //申请列表
		{
			List[] list = (List[]) obj;
			for (int i = 0; i < msg.length; i++) {
				if (obj[i] == null)
					break;
				msg[i] = "";
				if (list[i].m_type == FAMILY_APPLY_TYPE_ROLE)
				{
					msg[i] += "玩家" + list[i].m_name + "申请加入家族";
				}
				else
				{
					msg[i] += list[i].m_name + "家族申请合并家族";
				}
			}
		}
		return msg;
	}

	private void addListMessage(SimpleRole[] role)
	{
		m_family_Listbox.removeAllSubItem();
		for (int i = 0; i < role.length; i++)
		{
			DWListSubItem item = new DWListSubItem();

			DWLabel lable[] = new DWLabel[4];
			lable[0] = new DWLabel(role[i].m_name);

			String lv = "";
			String contrbution = "";
			if (role[i].m_online)
			{
				lv = "" + role[i].m_grade;
				contrbution = "" + role[i].m_contrbution;
			}
			else
			{
				lv = "-";
				contrbution = "-";
			}

			lable[1] = new DWLabel(lv);
			lable[2] = new DWLabel(contrbution);
			lable[3] = new DWLabel(FAMILY_POSITION[role[i].m_position - 1]);
			for (int j = 0; j < 4; j++)
			{
				item.addControls(lable[j]);

				lable[j].setBackgroundColor(Tools.ALPHA);
				if (!role[i].m_online)
				{
					lable[j].setTextColor(0xFF818080);
				}
				lable[j].setNearAnchorUn(item, Tools.HCENTER_TOP, Tools.LEFT_TOP, moveX * (j + 1), 0);

			}

			item.setAutoWideHigh(false);
			item.setShowWideHigh(m_family_Listbox.getShowWidth(), lable[0].getShowHeight() + 5);
			m_family_Listbox.addSubItem(item);
		}
		m_family_pageNum.setText("  " + (m_family_member_page + 1) + "/" + (m_family_member_amount) + "  ");

	}

	/**
	 * 设置申请列表框对象内容
	 * @param msgList
	 * @param msgBox
	 */
	private void setListbox(String[] msgList, DWTextbox[] msgListbox, int maxLength)
	{
		if (msgList != null && msgList.length > 0)
		{
			for (int i = 0; i < maxLength; i++) {
				if (msgList[i] != null)
					msgListbox[i].setText(msgList[i]);
				else
					msgListbox[i].setText(" ");
			}
		}
	}

	/**
	 * 设置文本框对象内容
	 * @param msgList 字符创数组
	 * @param msgBox 文本框对象
	 */
	private void setTextbox(String[] msgList, DWTextbox msgBox)
	{
		if (msgList != null && msgList.length > 0)
		{
			String msg = "";
			for (int i = 0; i < msgList.length; i++) {
				msg += msgList[i] + "`";
			}
			msgBox.setText(msg);
		}
	}

	private DWFrame m_qifu_frame;
	private DWTitle m_qifu_title;
	private DWImageBox m_qifu_close;
	private DWBackground m_qifu_windowBackground;
	private DWBackground m_qifu_messageBackground;
	public DWGrid[] m_qifu_grids = null;
	private DWTextbox m_qifu_Textbox;
	private DWButton m_qifu_buton;
	private DWTextbox m_qifu_num;
	private DWTextbox m_qifu_tips;
	private String qifuStr = "<mark c=FFBB11>祈福需要的贡献值，可通过完成任务，参与竞技场和副本获得</mark>";

	private String str = "";

//	private int[] m_index={4,5,3,6,2,7,1,8,0,9,10,17,11,16,12,15,13,14};
	private int[] m_index = { 13, 12, 11, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 16, 15, 14 };

	/**
	 * 祈福界面
	 */
	private void qifuFrame()
	{
		luckyStop();
		m_qifu_frame = new DWFrame(DWFrame.FRAME_TYPE_FULL);
		m_qifu_frame.setClickClose(false);

		m_qifu_title = new DWTitle("祈福", m_qifu_frame);
		m_qifu_title.setBackground(UIWindows.createImage("/img/newui/qifu_1.gnp"), false);
		m_qifu_frame.addControl(m_qifu_title);

		m_qifu_close = new DWImageBox(closeWimdow);
		m_qifu_close.setTouchZoomIn(UIFixWindow.TOUCHZOOM, UIFixWindow.TOUCHZOOM);
		m_qifu_close.setNearAnchor(m_qifu_title, Tools.RIGHT_TOP, Tools.RIGHT_TOP);
		m_qifu_close.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_qifu_frame);

				if (m_state == MAINWINDOW)
				{
					m_family_TabControl.setSelectPage(0);
					DWControlsManager.getInstance().addControl(m_family_Frame);
				}
			}
		});

		m_qifu_frame.addControl(m_qifu_close);

		m_qifu_windowBackground = new DWBackground(m_qifu_frame.getShowWidth() - 40, m_qifu_frame
				.getShowHeight() - 50);
		m_qifu_windowBackground.setNearAnchor(m_qifu_frame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);
		m_qifu_frame.addControl(m_qifu_windowBackground);

		m_qifu_messageBackground = new DWBackground(m_qifu_windowBackground.getShowWidth() / 2,
				m_qifu_windowBackground.getShowHeight() / 3);
		m_qifu_messageBackground.setNearAnchor(m_qifu_windowBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_qifu_frame.addControl(m_qifu_messageBackground);

		m_qifu_grids = null;
		m_qifu_grids = new DWGrid[m_family.m_lucky_item_amount];

		float moveX = (m_qifu_windowBackground.getShowWidth() - (qifuBoxImg.getWidth() * 8) - 40) / 9;
		int star_index = (m_index.length - m_family.m_lucky_item_amount) / 2;
		for (int i = 0; i < m_family.m_lucky_item_amount; i++) {
			m_qifu_grids[i] = new DWGrid(qifuBoxImg);
			setGrid(m_qifu_grids[i], m_index[star_index + i], moveX);
			m_qifu_grids[i].addObject(m_family.m_lucky_items[i]);
		}

		m_qifu_Textbox = new DWTextbox(str, m_qifu_messageBackground.getShowWidth() - 30, m_qifu_messageBackground
				.getShowHeight() - 30);
		m_qifu_Textbox.setNearAnchor(m_qifu_messageBackground, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		refreshLuckyMessage();
		m_qifu_frame.addControl(m_qifu_Textbox);

		m_qifu_buton = new DWButton("祈福", buttonImg);
		m_qifu_buton.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (DWGameManager.getInstance().getSendMessage().isNetLocked(GameMessage.锁_家族))
					return;

				if (m_lucky_surplus_count < 1)
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抽奖次数已用完~");
				else if (DWGameManager.getInstance().m_role.m_banggong < m_lucky_event_devote)
				{
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "家族贡献值不足~");
				}
				else
				{
				luckyStar();
				}
			}
		});
		m_qifu_buton.setDownImage(anxiabutonImg);
		m_qifu_buton.setNearAnchor(m_qifu_windowBackground, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -20, -20);
		m_qifu_frame.addControl(m_qifu_buton);

		m_qifu_num = new DWTextbox("");
		setQifuNum();
		m_qifu_frame.addControl(m_qifu_num);

		m_qifu_tips = new DWTextbox(qifuStr);
		m_qifu_tips.setNearAnchor(m_qifu_frame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM);
		m_qifu_frame.addControl(m_qifu_tips);

		DWControlsManager.getInstance().addControl(m_qifu_frame);
	}

	private void setQifuNum()
	{
		if (m_qifu_num != null)
		{
			String msg = "<mark c=9900FF>当前贡献值：</mark>" + DWGameManager.getInstance().m_role.m_banggong;
			m_qifu_num.setText(msg);
			m_qifu_num.setNearAnchor(m_qifu_windowBackground, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 20, -20);
		}
	}

	private void setGrid(DWGrid grid, int index, float moveX)
	{
		int anchor = 0;
		if (index > 0 && index < 9)
		{
			anchor = Tools.LEFT_TOP;
		}
		else if (index > 9 && index < 18)
		{
			anchor = Tools.LEFT_BOTTOM;
		}
		if (index == 0)
		{
			grid.setNearAnchor(m_qifu_windowBackground, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER,
					(int) (moveX + 20), 0);
		}
		else if (index == 9)
		{
			grid.setNearAnchor(m_qifu_windowBackground, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER,
					-(int) (moveX + 20), 0);
		}
		else
		{
			int moveY = 20;
			if (index == 1 || index == 8 || index == 17 || index == 10)
			{
				moveY += qifuBoxImg.getWidth();
			}
			else if (index == 2 || index == 7 || index == 16 || index == 11)
			{
				moveY += qifuBoxImg.getWidth() / 2;
			}
			if (index > 9)
				moveY = -moveY;
			grid.setNearAnchor(m_qifu_windowBackground, anchor, anchor, (int) (moveX * (index % 9)
					+ qifuBoxImg.getWidth() * ((index % 9) - 1) + 20), moveY);
		}
		m_qifu_frame.addControl(grid);
	}

	/***************************************************************************************************/
	/**
	 * 验证是否可以创建家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyVerify(DataInputStream dis) throws IOException
	{
		short status = dis.readShort();
		if (status == 1) {//成功
			addFamily();
		}
		else {
			String msg = dis.readUTF();
			Tools.debugPrintln(msg);
			DWGameManager.getInstance().showToast("家族未开启", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 创建家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyCreate(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		short status = dis.readShort();
		String msg = dis.readUTF();
		if (status == SUCCEED) {
			DWGameManager.getInstance().m_role.m_position = FAMILY_POSITION_SHAIKH;
			DWGameManager.getInstance().m_role.m_family_name = m_family_name;
			UIWindows.getInstance().m_family.open((byte) 0);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, msg);
		}
		else {
			final DWMessageBox mb = new DWMessageBox("提示", msg);
			mb.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(mb);
				}
			});
			DWControlsManager.getInstance().addControl(mb);
		}
	}

	/**
	 * 查看自己家族信息
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyOwnMessage(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		long id = dis.readLong();//家族ID 0失败 不继续读取
		Tools.debugPrintln("读取自己家族信息!" + id);
		if (id >= SUCCEED) {
			m_family = null;
			m_family = new Family();
			m_family.readOwnMessage(dis);
			m_family_position = (byte) (DWGameManager.getInstance().m_role.m_position - 1);

			if (m_family.m_dismiss_time > 0)
			{
				if (DWControlsManager.getInstance().contains(m_family_Frame))
					DWControlsManager.getInstance().removeControl(m_family_Frame);
				addFamilyDismiss();
			}
			else
			{
				switch (m_state) {
					case MAINWINDOW:
						m_frame_isFirst = true;

						initFrame();
						setTextbox(m_family.getOwnMessage(), m_family_MessageBox);
						setTextbox(m_family.getOwnLv(), m_family_lv1);
						setTextbox(m_family.getNextOwnLv(), m_family_lv2);

						DWControlsManager.getInstance().addControl(m_family_Frame);

						DWGameManager.getInstance().getSendMessage().sendFamilyMemberList((short) m_family_member_page,
								listboxMax);
						DWGameManager.getInstance().getSendMessage().sendFamilyApplyList((short) m_family_apply_page,
								supMaxList); // 查看申请列表
						DWGameManager.getInstance().getSendMessage().sendFamilyLuckyOpen();
						DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
						break;
					case QIFUWINDOW:
						m_frame_isFirst = false;
						qifuFrame();
						DWGameManager.getInstance().getSendMessage().sendFamilyLuckyOpen();
						DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);

						break;
				}

			}
		}
		else {
			addFamily();
		}
	}

	/**
	 * 读取其他家族的信息
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyOtherMessage(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);

		long familyID = dis.readLong();
		if (familyID > 0) {
			m_family = null;
			m_family = new Family();
			m_family.readOtherMessage(dis);
//			m_family_message = m_family.getOtherMessage();
			showOtherFamily(m_family);
		}
	}

	private DWFrame m_other_family;

	private void showOtherFamily(Family family)
	{
		if (DWControlsManager.getInstance().contains(m_other_family))
			DWControlsManager.getInstance().removeControl(m_other_family);

		m_other_family = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER);
		m_other_family.setTouchZoomIn(0, 0);
		m_other_family.setBackgroundColor(Tools.ALPHA);

		DWBackground background = new DWBackground(msgBackground, m_other_family.getShowWidth() - 40,
				m_other_family.getShowHeight() - 40);
		background.setNearAnchor(m_other_family, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_other_family.addControl(background);

		DWTextbox m_other_message = new DWTextbox("", background.getShowWidth() - 40, background.getShowHeight() - 60);
		m_other_message.setNearAnchor(background, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		setTextbox(family.getOtherMessage(), m_other_message);

		m_other_family.addControl(m_other_message);
		DWControlsManager.getInstance().addControl(m_other_family);
	}

	/**
	 * 读取修改家族宣言
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyModifyManifesto(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);

		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == SUCCEED) {
			m_family.m_manifesto = m_family_content;
			m_family_message = m_family.getOwnMessage();
			setTextbox(m_family.getOwnMessage(), m_family_MessageBox);
		}
	}

	/**
	 * 读取修改家族公告
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyModifyNotice(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == SUCCEED) {
			m_family.m_notice = m_family_content;
			m_family_message = m_family.getOwnMessage();
			setTextbox(m_family.getOwnMessage(), m_family_MessageBox);
		}
	}

	/**
	 * 读取更新家族职位
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyUpdatePosition(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		long id = dis.readLong();
		if (id == 0) {
			DWGameManager.getInstance().m_role.m_position = 0;
		}
		else {
			DWGameManager.getInstance().m_role.m_position = dis.readByte();
			DWGameManager.getInstance().m_role.m_banggong = dis.readLong();
			setQifuNum();
			Tools.debugPrintln("职位 : " + DWGameManager.getInstance().m_role.m_position + ", 贡献值 : "
					+ DWGameManager.getInstance().m_role.m_contribution);
		}
	}

	/**
	 * 读取家族成员列表
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyMemberList(DataInputStream dis) throws IOException
	{
		if (m_frame_isFirst)
		{
			netlock++;
			if (netlock > 2)
			{
				m_frame_isFirst = false;
				DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
				Tools.debugPrintln("接收信息，网络解锁");
			}
		}
		else
		{
			DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		}

		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 1) {
			m_family_member_page = dis.readShort();
			Tools.debugPrintln("当前页 : " + m_family_member_page);
			m_family_member_amount = dis.readShort();
			Tools.debugPrintln("总页 : " + m_family_member_amount);
			short size = dis.readShort();
			m_family_member_list = null;
			m_family_member_list = new SimpleRole[size];
			for (short i = 0; i < size; i++) {
				SimpleRole role = new SimpleRole();
				role.m_gameID = dis.readLong();
				Tools.debugPrintln("成员" + i + "ID : " + role.m_gameID);
				role.m_name = dis.readUTF();
				Tools.debugPrintln("成员" + i + "名字 : " + role.m_name);
				role.m_position = dis.readByte();
				Tools.debugPrintln("成员" + i + "职位 : " + role.m_position);
				role.m_online = dis.readByte() == 0 ? false : true;
				Tools.debugPrintln("成员" + i + "在线 : " + role.m_online);
				if (role.m_online) {
					role.m_grade = dis.readInt();
					Tools.debugPrintln("成员" + i + "等级 : " + role.m_grade);
					role.m_contrbution = dis.readLong();
					Tools.debugPrintln("成员" + i + "贡献 : " + role.m_contrbution);
				}
				m_family_member_list[i] = role;
			}
			addListMessage(m_family_member_list);
		}
	}

	/**
	 * 读取申请加入家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyApplyAdd(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 1) {
			DWGameManager.getInstance().showToast("申请成功! ", Toast.LENGTH_SHORT);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在! ", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够! ", Toast.LENGTH_SHORT);
		}
		else if (status == 4) {
			DWGameManager.getInstance().showToast("家族暂时不接受申请! ", Toast.LENGTH_SHORT);
		}
		else if (status == 7) {
			DWGameManager.getInstance().showToast("不能申请加入家族!", Toast.LENGTH_SHORT);
		}
		else if (status == 12) {
			DWGameManager.getInstance().showToast("家族在不同阵营不能申请!", Toast.LENGTH_SHORT);
		}
		else
		{
			DWGameManager.getInstance().showToast("提示 :未知错误! ", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取家族申请列表
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyApplyList(DataInputStream dis) throws IOException
	{
		if (m_frame_isFirst)
		{
			netlock++;
			if (netlock > 2)
			{
				m_frame_isFirst = false;
				DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
				Tools.debugPrintln("接收信息，网络解锁");
			}
		}
		else
			DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);

		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == SUCCEED) {
			m_family_apply_list = null;
			m_family_apply_list = new List[supMaxList];
			m_family_apply_page = dis.readShort();
			Tools.debugPrintln("当前页 : " + m_family_apply_page);
			m_family_apply_amount = dis.readShort();
			Tools.debugPrintln("总页 : " + m_family_apply_amount);
			long familyID = dis.readLong();
			Tools.debugPrintln("申请家族ID : " + familyID);
			if (familyID > 0) {
				List list = new List();
				list.m_id = familyID;
				list.m_name = dis.readUTF();
				Tools.debugPrintln("申请家族名字 : " + list.m_name);
				list.m_type = FAMILY_APPLY_TYPE_FAMILY;
				m_family_apply_list[0] = list;
			}
			short size = dis.readShort();
			for (int i = 0; i < size; i++) {
				List list = new List();
				list.m_id = dis.readLong();
				Tools.debugPrintln("申请人ID : " + list.m_id);
				list.m_name = dis.readUTF();
				Tools.debugPrintln("申请人名字 : " + list.m_name);
				list.m_type = FAMILY_APPLY_TYPE_ROLE;
//				m_family_apply_list.addElement(list);
				if (familyID > 0)
					m_family_apply_list[i + 1] = list;
				else
					m_family_apply_list[i] = list;
			}
			setListbox(getSting(m_family_apply_list), m_family_supTextbox, supMaxList);

			m_family_supPageNum.setText("  "
					+ (m_family_apply_amount > 0 ? m_family_apply_page + 1 : m_family_apply_page) + "/"
					+ (m_family_apply_amount) + "  ");
		}
	}

	/**
	 * 读取批准申请加入，合并
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyRatifyAdd(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		//status值待定
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知! ", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			DWGameManager.getInstance().showToast("操作成功! ", Toast.LENGTH_SHORT);
			m_family.m_nnt++;
			setTextbox(m_family.getOwnMessage(), m_family_MessageBox);
			DWGameManager.getInstance().getSendMessage().sendFamilyMemberList(
					(short) m_family_member_page, (short) listboxMax);
			DWGameManager.getInstance().getSendMessage().sendFamilyApplyList(
					(short) m_family_apply_page, (short) supMaxList);
			DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在! ", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够! ", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取通过名字或者ID邀请入族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyInviteAdd(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		//status值待定
		if (status == 1) {
			DWGameManager.getInstance().showToast("已发出邀请! ", Toast.LENGTH_SHORT);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在! ", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够! ", Toast.LENGTH_SHORT);
		}
		else if (status == 5) {
			DWGameManager.getInstance().showToast("邀请人不在线! ", Toast.LENGTH_SHORT);
		}
		else if (status == 6) {
			DWGameManager.getInstance().showToast("目标不能被邀请! ", Toast.LENGTH_SHORT);
		}
		else if (status == 12) {
			DWGameManager.getInstance().showToast("不同阵营,不能邀请加入! ", Toast.LENGTH_SHORT);
		}
		else if (status == 0)
		{
			DWGameManager.getInstance().showToast("未知错误! ", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 接收家族批准
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyRatify(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);

		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			DWGameManager.getInstance().m_role.m_position = FAMILY_POSITION_SHAIKH;
			final DWMessageBox mb = new DWMessageBox("提示", "已通过家族申请");
			mb.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(mb);
				}
			});
			DWControlsManager.getInstance().addControl(mb);

		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 确认离开家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyConfirmLeave(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		if (status == 0) {//未知错误
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {//成功
			DWGameManager.getInstance().m_role.m_family_name = null;
			DWGameManager.getInstance().m_role.m_position = 0;
			DWGameManager.getInstance().showToast("退出家族!", Toast.LENGTH_SHORT);
		}
		else if (status == 2) {//家族不存在
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 8) {//不能离开家族
			DWGameManager.getInstance().showToast("您是族长,不能离开家族!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取开除成员
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyExpel(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			DWGameManager.getInstance().showToast("开除成功!", Toast.LENGTH_SHORT);

			DWGameManager.getInstance().getSendMessage().sendFamilyMemberList(
					(short) m_family_member_page, (short) listboxMax);
			DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够！", Toast.LENGTH_SHORT);
		}
		else if (status == 8) {
			DWGameManager.getInstance().showToast("您是族长,不能离开家族!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取解散家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyDismiss(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {

			m_family.m_dismiss_time = dis.readLong();
			m_family.m_dismiss_total_time = m_family.m_dismiss_time;
			Tools.debugPrintln("解散剩余时间 : " + m_family.m_dismiss_time);
			DWGameManager.getInstance().showToast("申请解散成功!", Toast.LENGTH_SHORT);
			DWControlsManager.getInstance().removeControl(m_family_Frame);
			addFamilyDismiss();
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够!", Toast.LENGTH_SHORT);
		}
		else if (status == 4) {
			DWGameManager.getInstance().showToast("家族不接收申请!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取取消解散家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyCancelDismiss(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			m_family.m_dismiss_time = 0;
			m_family.m_dismiss_total_time = m_family.m_dismiss_time;
			Tools.debugPrintln("取消解散时间 : " + m_family.m_dismiss_time);
			DWControlsManager.getInstance().removeControl(m_dismiss_frame);
			DWGameManager.getInstance().showToast("取消解散成功!", Toast.LENGTH_SHORT);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 被邀请加入家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyInviteeAdd(DataInputStream dis) throws IOException
	{
		final Family family = new Family();
		family.m_shaikh_id = dis.readLong();
		Tools.debugPrintln("族长ID : " + family.m_shaikh_id);
		family.m_id = dis.readLong();
		Tools.debugPrintln("家族ID : " + family.m_id);
		family.m_name = dis.readUTF();
		Tools.debugPrintln("家族名字 : " + family.m_name);
		final DWMessageBox mb = new DWMessageBox("提示", family.m_name + "家族邀请您加入!");
		mb.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(mb);
				if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
					DWGameManager.getInstance().getSendMessage().sendFamilyInviteeAdd(FAMILY_INVITEE_AGREE,
							family.m_shaikh_id, family.m_id);
				}
				else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
					DWGameManager.getInstance().getSendMessage().sendFamilyInviteeAdd(FAMILY_INVITEE_REFUSE,
							family.m_shaikh_id, family.m_id);
				}
			}
		});

		DWControlsManager.getInstance().addControl(mb);
	}

	/**
	 * 读取提拔/免职长老
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilySetElder(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		Tools.debugPrintln("提拔/免职长老 状态 : " + status);
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			DWGameManager.getInstance().showToast("设置成功!", Toast.LENGTH_SHORT);
			DWGameManager.getInstance().getSendMessage().sendFamilyMemberList(
					(short) m_family_member_page, (short) listboxMax);
			DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够!", Toast.LENGTH_SHORT);
		}
		else if (status == 4) {
			DWGameManager.getInstance().showToast("长老名额达到上限!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取禅让族长
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyDemiseSheikh(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			DWGameManager.getInstance().showToast("设置成功!", Toast.LENGTH_SHORT);
			DWGameManager.getInstance().getSendMessage().sendFamilyMemberList(
					(short) m_family_member_page, (short) listboxMax);
			DWGameManager.getInstance().getSendMessage().lockNetwork(GameMessage.锁_家族);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够!", Toast.LENGTH_SHORT);
		}
		else if (status == 4) {
			DWGameManager.getInstance().showToast("对方不接受!", Toast.LENGTH_SHORT);
		}
	}

	/**
	 * 读取合并家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyApplyMerge(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!!", Toast.LENGTH_SHORT);
		}
		else if (status == 1) {
			DWGameManager.getInstance().showToast("申请合并家族成功!", Toast.LENGTH_SHORT);
		}
		else if (status == 2) {
			DWGameManager.getInstance().showToast("家族不存在!", Toast.LENGTH_SHORT);
		}
		else if (status == 3) {
			DWGameManager.getInstance().showToast("权限不够!", Toast.LENGTH_SHORT);
		}
		else if (status == 4) {
			DWGameManager.getInstance().showToast("合并条件不符合!", Toast.LENGTH_SHORT);
		}
		else if (status == 9) {
			DWGameManager.getInstance().showToast("需要道具!", Toast.LENGTH_SHORT);
		}
	}

	private int m_lucky_family_lv = 0;//家族等级
	private int m_lucky_day_count = 0;//每天可抽奖次数
	private int m_lucky_event_devote = 0;//每次消耗贡献
	private int m_lucky_surplus_count = 0;//剩余可抽奖次数
	private SimpleItem m_lucky_item; //获得的道具
	private int m_lucky_result = -1;

	/**
	 * 家族抽奖开启
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyLuckOpen(DataInputStream dis) throws IOException
	{
		if (m_frame_isFirst)
		{
			netlock++;
			if (netlock > 2)
			{
				m_frame_isFirst = false;
				DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
				Tools.debugPrintln("接收信息，网络解锁");
			}
		}
		else
		{
			DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		}

		byte status = dis.readByte();
		if (status == 1) {
			m_lucky_family_lv = dis.readInt();
			m_lucky_day_count = dis.readInt();
			m_lucky_event_devote = dis.readInt();
			m_lucky_surplus_count = dis.readInt();
			refreshLuckyMessage();
		}
		else if (status == 0) {
			DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);
		}
		else {
			DWGameManager.getInstance().showToast("没有家族!", Toast.LENGTH_SHORT);
		}
	}

	private void refreshLuckyMessage()
	{
		if (m_qifu_Textbox != null) {
			str = "家族等级" + m_lucky_family_lv +
					"`每天可以抽奖<mark c=55FF00>" + m_lucky_day_count + "</mark>次,每次消耗<mark c=55FF00>"
					+ m_lucky_event_devote
					+ "</mark>贡献值" +
					"`今日可抽奖<mark c=55FF00>" + m_lucky_surplus_count + "</mark>次";
			m_qifu_Textbox.setText(str);
		}
	}

	/**
	 * 抽奖结果获得
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyLuckResult(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		byte status = dis.readByte();
		Tools.debugPrintln("status=" + status);
		if (status == 1) {
			m_lucky_item = new SimpleItem();
			Tools.debugPrintln("m_lucky_item=" + m_lucky_item);
			m_lucky_result = dis.readByte();
			Tools.debugPrintln("m_lucky_result=" + m_lucky_result);
			m_lucky_item.m_name = dis.readUTF();
			Tools.debugPrintln("m_lucky_item.m_name=" + m_lucky_item.m_name);
			m_lucky_item.m_num = dis.readShort();
			Tools.debugPrintln("m_lucky_item.m_num" + m_lucky_item.m_num);
			m_lucky_surplus_count--;
		}
		else
		{
			if (status == 2) {
				DWGameManager.getInstance().showToast("没有家族!", Toast.LENGTH_SHORT);
			}
			else if (status == 10) {
				DWGameManager.getInstance().showToast("抽奖次数用完!", Toast.LENGTH_SHORT);
			}
			else if (status == 11) {
				DWGameManager.getInstance().showToast("家族贡献值不够!", Toast.LENGTH_SHORT);
			}
			else
				DWGameManager.getInstance().showToast("未知错误!", Toast.LENGTH_SHORT);

		}
	}

	/************************ 变量,常量,对象 **************************/
	private final byte SUCCEED = 1;//成功
	private String m_family_name = null;//家族名称
	private List[] m_family_apply_list = null;//家族申请列表(包含申请合并家族)
	private SimpleRole[] m_family_member_list = null;//家族成员列表
	private String[] m_family_message = null;//家族信息数组

	private String m_family_content = null;//临时的家族公告 宣言

	private short m_family_apply_page = 0;//家族申请列表当前页 从1开始
	private short m_family_apply_amount = 0;//家族申请列表总页数

	private short m_family_member_page = 0;//家族成员列表当前页 从1开始
	private short m_family_member_amount = 0;//家族成员列表总页数

	public final String[] FAMILY_MEMBER_LABEL = { "姓名", "级别", "职位" };

	public final String[][] FAMILY_MANAGE_MENU = {
			{ "捐献帮贡", "家贡商店", "退出家族" },
			{ "捐献帮贡", "家贡商店", "邀请入族", "退出家族" },
			{ "捐献帮贡", "家贡商店", "邀请入族", "家族合并", "家族解散", "退出家族" } };
	public final String[][] FAMILY_MEMBER_MENU = {
			{ "查看信息", "发送信件" },
			{ "查看信息", "发送信件", "开除成员", "禅让族长", "提拔长老" },
			{ "查看信息", "发送信件", "开除成员", "禅让族长", "免职长老" } };
	public final String[] FAMILY_POSITION = { "成员", "长老", "族长" };
	public final String[] FAMILY_LIST_MENU = { "同意", "拒绝" };

	public final byte FAMILY_INVITEE_AGREE = 0;//被邀请入族 同意
	public final byte FAMILY_INVITEE_REFUSE = 1;//拒绝

	public final byte FAMILY_RATIFY_TYPE_FAMILY = 0;//家族批准类型 - 家族
	public final byte FAMILY_RATIFY_TYPE_ROLE = 1;//家族批准类型 - 玩家

	public final byte FAMILY_POSITION_NONE = 0;//无职位
	public final byte FAMILY_POSITION_MEMBER = 1;//成员
	public final byte FAMILY_POSITION_ELDER = 2;//长老
	public final byte FAMILY_POSITION_SHAIKH = 3;//族长

	public final byte FAMILY_SETELDER_PROMOTION = 0;//提拔
	public final byte FAMILY_SETELDER_DEPOSE = 1;//免职

	public final byte FAMILY_APPLY_TYPE_FAMILY = 0;//家族申请列表内容类型 - 家族合并
	public final byte FAMILY_APPLY_TYPE_ROLE = 1;//玩家

	/******************************************************************************************************/
	class List
	{
		public long m_id = 0;
		public String m_name = null;
		public byte m_type = 0;
	}

	class SimpleItem implements IIcon
	{
		public Bitmap m_icon;
		public Bitmap m_pinzhi;

		public String m_name;
		public int m_iconId;//icon
		public int m_quality;//品质
		public int m_num; //索引

		public void recvItemFormServer(DataInputStream dis) throws IOException
		{
			m_name = dis.readUTF();
			Tools.debugPrintln("item 名称" + m_name);
			m_num = dis.readShort();
			Tools.debugPrintln("item 数量" + m_num);
			m_iconId = dis.readShort();
			Tools.debugPrintln("item 图标id" + m_iconId);
			m_quality = dis.readShort();
			Tools.debugPrintln("item 品质" + m_quality);

			m_icon = IconManger.getInstance().getIcon(m_iconId);
			if (m_quality > 0 && m_quality < 7)
				m_pinzhi = IconManger.getInstance().getPinzhi(m_quality);
		}

		public void drawIcon(DWGraphics g, int x, int y, int w, int h, int anchor)
		{
			if (m_icon != null) {
				g.drawBitmap(m_icon, x, y, anchor);
			}
			if (m_pinzhi != null) {
				g.drawBitmap(m_pinzhi, x, y, w, h, anchor);
			}
			if (m_num > 1) {
				float tempX = x - (w >> 1);
				float tempY = y + ((h >> 1) - DWFont.getDefaultFont().getHeight());
				String temp = "" + m_num;
				g.drawString(temp, Color.WHITE, tempX, tempY, 0);
			}
		}

		public void drawIcon(DWGraphics g, int x, int y, int w, int h, float scaleX, float scaleY, int anchor)
		{
		}

	}

	class Family
	{
		public long m_id = 0;//家族ID
		public long m_shaikh_id = 0;//族长ID
		public String m_name = null;//家族名称
		public String m_notice = null;//家族公告 外部
		public String m_manifesto = null;//家族宣言 内部
		public String m_shaikh_name = null;//族长名字
		public int m_lv = 0;//等级
		public int m_nnt = 0;//当前人数
		public int m_nnt_max = 0;//人数上限
		public int m_exp = 0;//当前经验
		public int m_exp_max = 0;//升级经验
		public byte m_faction = 0;//阵营
		public long m_dismiss_time = 0;//解散剩余时间
		public long m_dismiss_total_time = 0;//解散剩余总时间
		public int m_zl = 0;//长老数量
		public int m_next_nnt_max = 0;//下一级人数上限
		public int m_next_exp_max = 0;//下一级升级经验
		public int m_next_zl = 0;//下一级长老数量
		public int m_lucky_day_count = 0;//祈福数量
		public int m_next_lucky_day_count = 0;//下一级祈福数量
		public String m_descript = null;//活动描述
		public String m_next_descript = null;//下一级活动描述
		public String m_next_lucky_day_message = null;//下一级祈福道具
		public byte m_lucky_item_amount = 0;//抽奖道具数量
		public SimpleItem[] m_lucky_items; //抽奖道具数组

		/**
		 * 得到自己家族的信息数组
		 */
		public String[] getOwnMessage()
		{
			String[] text = {
					"家族名称：" + m_name,
					"家族等级：" + m_lv,
					"族长：" + m_shaikh_name,
					"阵营：" + UIRoleStatsWindow.ROLE_FACTION_LIST[m_faction],
					"人数：" + m_nnt + "/" + m_nnt_max,
					"家族升级经验：" + m_exp + "/" + m_exp_max,
					"家族宣言：" + m_manifesto,
					"家族公告：" + m_notice };
			return text;
		}

		/**
		 * 得到其他家族的信息数组
		 */
		public String[] getOtherMessage()
		{
			String[] text = {
					"家族名称：" + m_name,
					"族长：" + m_shaikh_name,
					"阵营：" + UIRoleStatsWindow.ROLE_FACTION_LIST[m_faction],
					"等级：" + m_lv,
					"人数：" + m_nnt + "/" + m_nnt_max,
					"家族升级经验：" + m_exp + "/" + m_exp_max,
					"家族公告 : " + m_notice };
			return text;
		}

		/**
		 * 读取当前家族等级信息
		 * @return
		 */

		public String[] getOwnLv()
		{
			String[] text = {
					"家族等级：" + m_lv,
					"人数上限：" + m_nnt_max,
					"需要家族升级经验：" + m_exp_max,
					"长老数量：" + m_zl,
					"每日祈福数量：" + m_lucky_day_count,
					"祈福奖励：" + getLuckday(),
					"家族副本等级：" + m_lv + "级",
					"家族活动：" + m_descript };
			return text;
		}

		private String getLuckday()
		{
			StringBuffer str = new StringBuffer("");
			if (m_lucky_items != null)
			{
				for (int i = 0; i < m_lucky_items.length; i++)
				{
					str.append(m_lucky_items[i].m_name);
					if (i != m_lucky_items.length - 1)
						str.append(",");
				}
			}

			return str.toString();
		}

		/**
		 * 读取下一级家族等级信息
		 * @return
		 */
		public String[] getNextOwnLv()
		{
			int m_next_lv = m_lv;
			if (m_next_exp_max != m_exp_max)
				m_next_lv++;

			String[] text = {
					"家族等级：" + m_next_lv,
					"人数上限：" + m_next_nnt_max,
					"需要家族升级经验：" + m_next_exp_max,
					"长老数量：" + m_next_zl,
					"每日祈福数量：" + m_next_lucky_day_count,
					"祈福奖励：" + m_next_lucky_day_message,
					"家族副本等级：" + m_next_lv + "级",
					"家族活动：" + m_next_descript };
			return text;
		}

		/**
		 * 读取一个其他家族的信息
		 * @param dis
		 * @throws IOException
		 */
		public void readOtherMessage(DataInputStream dis) throws IOException
		{
			Tools.debugPrintln("读取一个自己家族信息");
			m_shaikh_id = dis.readLong();
			Tools.debugPrintln("族长ID : " + m_shaikh_id);
			m_shaikh_name = dis.readUTF();
			Tools.debugPrintln("族长名字 : " + m_shaikh_name);
			m_faction = dis.readByte();
			Tools.debugPrintln("家族阵营 : " + m_faction);
			m_name = dis.readUTF();
			Tools.debugPrintln("家族名字 : " + m_name);
			m_lv = dis.readInt();
			Tools.debugPrintln("家族等级 : " + m_lv);
			m_exp = dis.readInt();
			Tools.debugPrintln("当前经验 : " + m_exp);
			m_exp_max = dis.readInt();
			Tools.debugPrintln("升级经验 : " + m_exp_max);
			m_notice = dis.readUTF();
			Tools.debugPrintln("家族公告 : " + m_notice);
			m_nnt = dis.readInt();
			Tools.debugPrintln("家族人数 : " + m_nnt);
			m_nnt_max = dis.readInt();
			Tools.debugPrintln("人数上限 : " + m_nnt_max);
		}

		/**
		 * 家族列表读取家族信息
		 */

		public void readOtherList(DataInputStream dis) throws IOException
		{
			m_id = dis.readLong();
			Tools.debugPrintln("家族ID : " + m_id);
			m_name = dis.readUTF();
			Tools.debugPrintln("家族名字 : " + m_name);
			m_lv = dis.readInt();
			Tools.debugPrintln("家族等级 : " + m_lv);
			m_faction = dis.readByte();
			Tools.debugPrintln("家族阵营 : " + m_faction);
			m_nnt = dis.readInt();
			Tools.debugPrintln("m_nnt=" + m_nnt);
			m_nnt_max = dis.readInt();
			Tools.debugPrintln("m_nnt_max=" + m_nnt_max);
		}

		/**
		 * 读取一个自己家族的信息
		 * @param dis
		 * @throws IOException
		 */
		public void readOwnMessage(DataInputStream dis) throws IOException
		{
			Tools.debugPrintln("读取一个自己家族信息");
			m_shaikh_id = dis.readLong();
			Tools.debugPrintln("族长ID : " + m_shaikh_id);
			m_shaikh_name = dis.readUTF();
			Tools.debugPrintln("族长名字 : " + m_shaikh_name);
			m_faction = dis.readByte();
			Tools.debugPrintln("家族阵营 : " + m_faction);
			m_name = dis.readUTF();
			Tools.debugPrintln("家族名字 : " + m_name);
			m_lv = dis.readInt();
			Tools.debugPrintln("家族等级 : " + m_lv);
			m_exp = dis.readInt();
			Tools.debugPrintln("当前经验 : " + m_exp);
			m_exp_max = dis.readInt();
			Tools.debugPrintln("升级经验 : " + m_exp_max);
			m_next_exp_max = dis.readInt();
			Tools.debugPrintln("下一级升级经验 : " + m_next_exp_max);
			m_manifesto = dis.readUTF();
			Tools.debugPrintln("家族宣言 : " + m_manifesto);
			m_notice = dis.readUTF();
			Tools.debugPrintln("家族公告 : " + m_notice);
			m_nnt = dis.readInt();
			Tools.debugPrintln("家族人数 : " + m_nnt);
			m_nnt_max = dis.readInt();
			Tools.debugPrintln("人数上限 : " + m_nnt_max);
			m_next_nnt_max = dis.readInt();
			Tools.debugPrintln("下一级人数上限 : " + m_next_nnt_max);
			m_dismiss_time = dis.readLong();
			Tools.debugPrintln("解散时间 : " + m_dismiss_time);
			if (m_dismiss_time > 0) {
				m_dismiss_total_time = dis.readLong();
				Tools.debugPrintln("解散时间上限 : " + m_dismiss_total_time);
			}

			m_descript = dis.readUTF();
			Tools.debugPrintln("活动描述 : " + m_descript);
			m_next_descript = dis.readUTF();
			Tools.debugPrintln("下一级活动描述 : " + m_next_descript);
			m_lucky_day_count = dis.readShort();
			Tools.debugPrintln("每日抽奖次数: " + m_lucky_day_count);
			m_next_lucky_day_count = dis.readShort();
			Tools.debugPrintln("下一级每日抽奖次数: " + m_next_lucky_day_count);
			m_zl = dis.readShort();
			Tools.debugPrintln("长老数量: " + m_zl);
			m_next_zl = dis.readShort();
			Tools.debugPrintln("下一级长老数量: " + m_next_zl);

			m_lucky_item_amount = dis.readByte();
			Tools.debugPrintln("抽奖道具个数: " + m_lucky_item_amount);
			m_lucky_items = null;
			if (m_lucky_item_amount > 0) {
				m_lucky_items = new SimpleItem[m_lucky_item_amount];
				for (short i = 0; i < m_lucky_item_amount; i++) {
					m_lucky_items[i] = new SimpleItem();
					m_lucky_items[i].recvItemFormServer(dis);
				}
			}
			else {
				Tools.debugPrintln("家族抽奖数据错误0道具列表!");
			}

			m_next_lucky_day_message = dis.readUTF();
		}
	}

	private boolean m_lucky_start = false;
	private final static int m_lucky_wait_time = 50;
	private int m_lucky_select;
	private long m_star_time = 0;
	private long m_timer = 0;
	private int time = 0;
	private int m_lucky_playTime;
	private boolean m_sendLuck = false;
	private long m_dismiss_star_time = 0;
	private DWLabel m_dismiss_time_lable;
	private long m_dismiss_time;
	private long dissmiss_time = 0;

	public void logic()
	{
		

		if (m_lucky_start) {
			if (m_qifu_frame == null || (!DWControlsManager.getInstance().contains(m_qifu_frame)))
				return;
			
			long currentTime = System.currentTimeMillis();
			if (m_star_time == 0)
			{
				m_star_time = currentTime;
				m_timer = 0;
			}

			m_timer = currentTime - m_star_time;

			if (m_timer > m_lucky_wait_time * time)
			{
				time++;
				m_qifu_grids[m_lucky_select].setSelect(false);
				m_lucky_select++;
				if (m_lucky_select == m_qifu_grids.length)
					m_lucky_select = 0;
				m_qifu_grids[m_lucky_select].setSelect(true);
			}

			if (m_timer > m_lucky_playTime) {
				if (!m_sendLuck)
				{
					m_sendLuck = true;
					DWGameManager.getInstance().getSendMessage().sendFamilyLuckyResult();
				}
			}

			if (m_lucky_result > -1 && m_lucky_result == m_lucky_select)
			{
				luckyStop();
				refreshLuckyMessage();
				luckyGoods();
			}
		}

		//家族解散倒计

		if (m_family != null && m_family.m_dismiss_time > 0)
		{
			long currentTime = System.currentTimeMillis();
			if (m_dismiss_star_time == 0)
			{
				m_dismiss_star_time = currentTime;
				m_dismiss_time = 0;
				dissmiss_time = 0;
			}

			m_dismiss_time = currentTime - m_dismiss_star_time;
			if (m_dismiss_time >= 1000 * dissmiss_time)
			{
				dissmiss_time++;
				if (m_dismiss_time_lable != null)
				{
					m_dismiss_frame.removeControl(m_dismiss_time_lable);
				}
				m_dismiss_time_lable = new DWLabel(UIBag
						.getTime(m_family.m_dismiss_time - dissmiss_time, UIBag.DAYTYPE));
				m_dismiss_time_lable.setNearAnchor(m_dismiss_bar, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
				m_dismiss_time_lable.setBackgroundColor(Tools.ALPHA);
				m_dismiss_frame.addControl(m_dismiss_time_lable);
			}
		}
	}

	DWFrame frame;

	/**
	 * 抽奖结果
	 */
	private void luckyGoods()
	{
		if (DWControlsManager.getInstance().contains(frame))
		{
			DWControlsManager.getInstance().removeControl(frame);
			frame = null;
		}

		frame = new DWFrame(DWGameManager.Screen_Width / 3, DWGameManager.Screen_Height / 2 + 40);
		frame.setTouchZoomIn(0, 0);
		DWGrid img = new DWGrid(qifuBoxImg);
		img.addObject(m_family.m_lucky_items[m_lucky_result]);
		img.setDarg(false);
		DWTextbox msg = new DWTextbox("恭喜您获得了``<mark c=00ff78>" + m_lucky_item.m_name + "x" + m_lucky_item.m_num
				+ "</mark>", 200, 100);

		img.setNearAnchor(frame, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER,
				(frame.getShowWidth() - msg.getShowWidth()) / 2, 0);
		msg.setNearAnchor(img, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);
		frame.addControl(img);
		frame.addControl(msg);
		DWControlsManager.getInstance().addControl(frame);
	}

	/**
	 * 开始抽奖
	 */
	private void luckyStar()
	{
		if (!m_lucky_start)
		{
			m_sendLuck = false;
			m_lucky_start = true;
			time = 0;
			m_star_time = 0;
			m_lucky_select = Tools.random(0, m_qifu_grids.length - 1);
			m_lucky_item = null;
			m_lucky_playTime = m_lucky_wait_time * 10 * m_family.m_lucky_item_amount;
			m_lucky_result = -1;
		}
	}

	/**
	 * 抽奖停止
	 */
	private void luckyStop()
	{
		m_lucky_start = false;
		time = 0;
		m_timer = 0;
		m_star_time = 0;
		m_lucky_select = 0;
		m_lucky_playTime = 0;
	}

	//////////////////////////////////////////////
	private DWFrame m_familyList_Frame;
	private DWTitle m_familylist_title;
	private DWBackground m_familylist_background;
	private DWBackground m_familylist_titleBackground;
	private DWImageBox m_familylist_close;
	private DWListbox m_familylist_listbox;
	private DWImageBox m_familylist_beforpage;
	private DWImageBox m_familylist_nextpage;
	private DWTextbox m_famliylist_pageNum;
	private short m_familylist_page = 0;//家族列表当前页数
	private short m_familylist_amount = 0;//家族列表总页数
	private short m_familylist_perPage = 0;//每页个数，固定值
	private Family[] m_familylist;

	private void initFamilyListDate()
	{
		m_familylist_page = 0;//家族列表当前页数
		m_familylist_amount = 0;//家族列表总页数
		m_familylist_perPage = 0;//每页个数，固定值
		m_familylist = null;
	}

	/**
	 * 家族列表
	 */
	private void openFamilyList()
	{
		initFamilyListDate();

		m_familyList_Frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER);
		m_familyList_Frame.setClickClose(false);

		m_familylist_title = new DWTitle("家族列表", m_familyList_Frame);
		m_familyList_Frame.addControl(m_familylist_title);

		m_familylist_close = new DWImageBox(closeWimdow);
		m_familylist_close.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_familyList_Frame);
				DWControlsManager.getInstance().addControl(m_family_Frame);
			}
		});
		m_familylist_close.setTouchZoomIn(UIFixWindow.TOUCHZOOM, UIFixWindow.TOUCHZOOM);
		m_familylist_close.setNearAnchor(m_familylist_title, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER);
		m_familyList_Frame.addControl(m_familylist_close);

		m_familylist_background = new DWBackground(m_familyList_Frame.getShowWidth() - 20, m_familyList_Frame
				.getShowHeight() - 50);
		m_familylist_background.setNearAnchor(m_familyList_Frame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM,0,-20);
		m_familyList_Frame.addControl(m_familylist_background);

		m_familylist_titleBackground = new DWBackground(listTitle, m_familylist_background.getShowWidth(), 30);
		m_familylist_titleBackground
				.setNearAnchor(m_familylist_background, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 10);
		m_familyList_Frame.addControl(m_familylist_titleBackground);

		String title[] = { "家族", "等级", "人数" };
		DWLabel[] titleLabel = new DWLabel[3];
		int width = m_familylist_titleBackground.getShowWidth() / 3;
		for (int i = 0; i < 3; i++)
		{
			titleLabel[i] = new DWLabel(title[i]);
			titleLabel[i].setBackgroundColor(Tools.ALPHA);
//			titleLabel[i].setTextColor(0xFFFFBB11);
			switch (i) {
				case 0:
					titleLabel[i].setShowWideHigh(width + 20, 30);
					break;
				case 1:
					titleLabel[i].setShowWideHigh(width - 20, 30);
					break;
				default:
					titleLabel[i].setShowWideHigh(width, 30);
					break;
			}
//			titleLabel[i].setShowWideHigh(width, 30);
			if (i == 0)
				titleLabel[i].setNearAnchor(m_familylist_titleBackground, Tools.LEFT_TOP, Tools.LEFT_TOP);
			else
				titleLabel[i].setNearAnchor(titleLabel[i - 1], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);
			m_familyList_Frame.addControl(titleLabel[i]);
		}

		m_famliylist_pageNum = new DWTextbox("  0/0  ");
		m_famliylist_pageNum.setNearAnchor(m_familylist_background, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0,
				-(beforePage.getHeight() - m_famliylist_pageNum.getShowHeight()) / 2);
		m_familyList_Frame.addControl(m_famliylist_pageNum);

		m_familylist_beforpage = new DWImageBox(beforePage);
		m_familylist_beforpage.setNearAnchor(m_famliylist_pageNum, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, -10, 0);
		m_familylist_beforpage.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_familylist_page == 0)
				{
					DWGameManager.getInstance().showToast("这已经是第一页了", Toast.LENGTH_SHORT);
				}
				else
				{
					DWGameManager.getInstance().getSendMessage().sendFamilyList(
							(short) (m_familylist_page - 1),
							m_familylist_perPage);
				}
			}
		});
		m_familyList_Frame.addControl(m_familylist_beforpage);

		m_familylist_nextpage = new DWImageBox(nextPage);
		m_familylist_nextpage.setNearAnchor(m_famliylist_pageNum, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
		m_familylist_nextpage.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_familylist_page < (m_familylist_amount - 1))
				{
					DWGameManager.getInstance().getSendMessage().sendFamilyList(
							(short) (m_familylist_page + 1),
							m_familylist_perPage);
				}
				else
				{
					DWGameManager.getInstance().showToast("这已经是最后一页了", Toast.LENGTH_SHORT);
				}
			}
		});
		m_familyList_Frame.addControl(m_familylist_nextpage);

		m_familylist_listbox = new DWListbox(m_familylist_background.getShowWidth(), m_familylist_background
				.getShowHeight()
				- m_familylist_titleBackground.getShowHeight() - 10 - nextPage.getHeight());
		m_familylist_listbox.setLineSpacing(5);
		m_familylist_listbox.setNearAnchor(m_familylist_titleBackground, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 5);
		m_familyList_Frame.addControl(m_familylist_listbox);

		/////为计算有多少行无实际显示用途
		if (listboxMax <= 0)
		{
			DWTextbox text = new DWTextbox("  ");
			m_familylist_perPage = (short) (m_familylist_listbox.getShowHeight() / (text.getShowHeight() + 5) - 1);
			Tools.debugPrintln("m_familylist_perPage-----------------------》" + m_familylist_perPage);
		}

		m_familylist_listbox.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_familylist[m_familylist_listbox.getTouchIndex()] != null)
				{
					final Family family = m_familylist[m_familylist_listbox.getTouchIndex()];

					final String[] popMenu = { "家族详情", "申请加入" };
					final DWPopMenu itemMenu = new DWPopMenu(popMenu, popMenuImg);
					itemMenu.setDownImage(popAnxiaMenuImg);
					itemMenu.addListener(new DWListener() {
						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							m_familyList_Frame.removeControl(itemMenu);
							switch (itemMenu.getIndex()) {
								case 0:
									DWGameManager.getInstance().getSendMessage().sendFamilyOtherMessage(family.m_id);
									break;
								case 1:
									DWGameManager.getInstance().getSendMessage().sendFamilyApplyAdd(family.m_id);
									break;
							}
						}
					});

					m_familyList_Frame.addControl(itemMenu);
				}
			}
		});

		DWControlsManager.getInstance().addControl(m_familyList_Frame);
		DWGameManager.getInstance().getSendMessage().sendFamilyList(m_familylist_page, m_familylist_perPage);
	}

	/**
	 * 家族列表
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyList(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		m_familylist_page = dis.readShort();
		Tools.debugPrintln("m_familylist_page=" + m_familylist_page);
		m_familylist_amount = dis.readShort();
		Tools.debugPrintln("m_familylist_amount=" + m_familylist_amount);
		short coumnt = dis.readShort();
		Tools.debugPrintln("coumnt=" + coumnt);
		m_familylist = null;
		if (coumnt > 0)
		{
			m_familylist = new Family[coumnt];
			for (int i = 0; i < coumnt; i++)
			{
				m_familylist[i] = new Family();
				m_familylist[i].readOtherList(dis);
			}
		}
		setFamilyList();
		setFamilyListPageNum();
	}

//	/**
//	 * 简易家族类
//	 * @author Administrator
//	 * 
//	 */
//	class SimpleFamily
//	{
//		public long m_ID; //家族ID
//		public 
//		public String m_name;//家族名称
//		public int m_lv; //家族级别
//		public int m_camp; //家族阵营
//		public int m_nnt = 0;//当前人数
//		public int m_nnt_max = 0;//人数上限
//
//		public void revcSmipleFamilyMessage(DataInputStream dis) throws IOException
//		{
//			m_ID = dis.readLong();
//			Tools.debugPrintln("m_ID="+m_ID);
//			m_name = dis.readUTF();
//			Tools.debugPrintln("m_name="+m_name);
//			m_lv = dis.readInt();
//			Tools.debugPrintln("m_lv="+m_lv);
//			m_camp = dis.readInt();
//			Tools.debugPrintln("m_camp="+m_camp);
//			m_nnt = dis.readInt();
//			Tools.debugPrintln("m_nnt="+m_nnt);
//			m_nnt_max = dis.readInt();
//			Tools.debugPrintln("m_nnt_max="+m_nnt_max);
//		}
//	}

	///////////////////////////////数据接收，刷新界面

	/**
	 * 刷新家族列表
	 */
	private void setFamilyList()
	{
		m_familylist_listbox.removeAllSubItem();
		int showWidth = m_familylist_listbox.getShowWidth() / 3;

		if (m_familylist != null)
		{
			for (int i = 0; i < m_familylist.length; i++)
			{
				DWListSubItem subitem = new DWListSubItem();
				DWLabel[] label = new DWLabel[3];

				for (int j = 0; j < label.length; j++)
				{
					String lableStr = "";
					switch (j) {
						case 0:
							lableStr = m_familylist[i].m_name;
							break;
						case 1:
							lableStr += m_familylist[i].m_lv;
							break;
						case 2:
							lableStr = m_familylist[i].m_nnt + "/" + m_familylist[i].m_nnt_max;
							break;
					}
					label[j] = new DWLabel(lableStr);

					switch (j) {
						case 0:
							label[j].setShowWideHigh(showWidth + 20, label[j].getShowHeight());
							break;
						case 1:
							label[j].setShowWideHigh(showWidth - 20, label[j].getShowHeight());
							break;
						default:
							label[j].setShowWideHigh(showWidth, label[j].getShowHeight());
							break;
					}
//					label[j].setShowWideHigh(showWidth, label[j].getShowHeight());

					//设置标签位置
					if (j == 0)
					{
						label[j].setNearAnchor(subitem, Tools.LEFT_TOP, Tools.LEFT_TOP);

						//设置字体颜色
						if (m_familylist[i].m_faction == 2) {
							label[j].setTextColor(0xFF00fffc);
						}
						else if (m_familylist[i].m_faction == 1) {
							label[j].setTextColor(0xFFf0480d);
						}
					}
					else
						label[j].setNearAnchor(label[j - 1], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER);

					label[j].setBackgroundColor(Tools.ALPHA);
					subitem.addControls(label[j]);
				}
				m_familylist_listbox.addSubItem(subitem);
			}
		}
	}

	/**
	 * 刷新家族列表页码
	 */
	private void setFamilyListPageNum()
	{
		m_famliylist_pageNum.setText((m_familylist_page + 1) + "/" + m_familylist_amount);
		m_famliylist_pageNum.refreshControl();
		m_famliylist_pageNum.setNearAnchor(m_familylist_background, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -(beforePage.getHeight() - m_famliylist_pageNum.getShowHeight()) / 2);
	}

	/************************************************************** 家族技能**************************************************************/
	//数值变量
	private int m_familySkill_numLeft = 10;//左侧技能个数
	private int m_familySkill_numRight = 10;//左侧技能个数
	private String m_str = "aaa";
	//控件
	private Bitmap m_family_ditu = null;
	
	private DWLabel m_family_rightLabel = null;
	private DWLabel m_family_leftLabel = null;
	private DWListbox m_family_rightListBox = null;//右侧的listbox
	private DWListSubItem[] m_right_subItem;//
	private DWImageBox[] m_right_imageSkill;//右侧技能图标
	private DWButton[] m_right_buttonSkill;//右侧按钮
	private DWImageBox[] m_right_skillIcon;
	private Bitmap[] m_bm_iconRight;
	private Bitmap m_right_button01 = null;
	private Bitmap m_right_button02 = null;
	private Actor m_right_abox = null;
	
	private DWListbox m_family_leftListBox = null;//左侧的listBox
	private DWListSubItem[] m_left_subItem;//
	private DWImageBox[] m_left_imageSkill;//左侧技能图标
	private DWTextbox[] m_left_textSkill;//左侧的技能描述
	private DWImageBox[] m_left_textSkillimage;//左侧的技能底图
	private Bitmap m_left_image = null;
	private DWButton[] m_left_buttonSkill;//左侧按钮
	private DWImageBox[] m_left_skillIcon;
	private Bitmap[] m_bm_iconLeft;
	private Bitmap m_left_button01 = null;
	private Bitmap m_left_button02 = null;
	private Actor m_left_abox = null;
	//成长点
	private DWTextbox m_familySkill_familyNum = null;
	private DWTextbox m_familySkill_ownNum = null;
	
	private void familySkill(){
		m_family_lvleftBackground = new DWBackground(xiaoBackground, m_family_TabControl.getShowWidth()*2/3 - 10,
				m_family_TabControl.getShowHeight() - tabSelectImg.getHeight() - 20 - 30);
		m_family_lvleftBackground.setNearAnchor(m_family_pages[JINENG], Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10);
		m_family_pages[JINENG].addControls(m_family_lvleftBackground);

		m_family_lvrightBackground = new DWBackground(xiaoBackground, m_family_TabControl.getShowWidth()/3 -10,
				m_family_lvleftBackground.getShowHeight());
		m_family_lvrightBackground.setNearAnchor(m_family_pages[JINENG], Tools.RIGHT_TOP, Tools.RIGHT_TOP, -10, 10);
		m_family_pages[JINENG].addControls(m_family_lvrightBackground);
		//技能点数
		if(m_familySkill_familyNum != null){
			m_familySkill_familyNum.setText("");
			m_familySkill_familyNum=null;
		}
		m_familySkill_familyNum = new DWTextbox("家族成长点："+m_familySkill_chengzhangdian);
		m_familySkill_familyNum.setNearAnchor(m_family_lvleftBackground, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 0);
		m_family_pages[JINENG].addControls(m_familySkill_familyNum);
		
		if(m_familySkill_ownNum != null){	
			m_familySkill_ownNum.setText("");
			m_familySkill_ownNum = null;
		}
		m_familySkill_ownNum = new DWTextbox("个人贡献值："+m_familySkill_gongxiandian);
		m_familySkill_ownNum.setNearAnchor(m_family_lvrightBackground, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 0);
		m_family_pages[JINENG].addControls(m_familySkill_ownNum);
		
		//标签左
		m_family_leftLabel = new DWLabel("技能列表");
		m_family_leftLabel.setShowBackground(false);
		m_family_leftLabel.setShowWideHigh(m_family_lvleftBackground.getShowWidth(), DWFont.getDefaultFont().getHeight());
		m_family_leftLabel.setNearAnchor(m_family_lvleftBackground, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 0);
		m_family_pages[JINENG].addControls(m_family_leftLabel);
		//标签右
		m_family_rightLabel = new DWLabel("技能列表");
		m_family_rightLabel.setShowBackground(false);
		m_family_rightLabel.setShowWideHigh(m_family_lvrightBackground.getShowWidth(),DWFont.getDefaultFont().getHeight());
		m_family_rightLabel.setNearAnchor(m_family_lvrightBackground, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 0);
		m_family_pages[JINENG].addControls(m_family_rightLabel);
		
		//左侧技能列表list
		m_family_leftListBox = new DWListbox(m_family_leftLabel.getShowWidth()-DWGameManager.Screen_Width*5/128, m_family_lvleftBackground.getShowHeight() - m_family_leftLabel.getShowHeight());
		m_family_leftListBox.setShowBackgroundRect(false);
		m_family_leftListBox.setNearAnchor(m_family_leftLabel, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 0);
		//刷新左侧的listBox	
		refreshLeftSkill();
		m_family_pages[JINENG].addControls(m_family_leftListBox);
		
		//右侧的listbox
		m_family_rightListBox = new DWListbox(m_family_rightLabel.getShowWidth() - DWGameManager.Screen_Width/64, m_family_lvrightBackground.getShowHeight() - m_family_rightLabel.getShowHeight());
		m_family_rightListBox.setShowBackgroundRect(false);
		m_family_rightListBox.setNearAnchorUn(m_family_rightLabel, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 0);
		refreshRightSkill();
		m_family_pages[JINENG].addControls(m_family_rightListBox);
		
	}
	/**刷新左侧的技能listbox*/
	private void refreshLeftSkill(){
		if(m_family_leftListBox == null){
			return;
		}
		m_family_leftListBox.removeAllSubItem();
		
		m_left_subItem = new DWListSubItem[m_familySkill_numLeft];
		m_left_imageSkill = new DWImageBox[m_familySkill_numLeft];//技能图标
		m_left_skillIcon = new DWImageBox[m_familySkill_numLeft];
		m_bm_iconLeft = new Bitmap[m_familySkill_numLeft];
		m_left_textSkill = new DWTextbox[m_familySkill_numLeft];//技能说明
		m_left_textSkillimage = new DWImageBox[m_familySkill_numLeft];
		m_left_buttonSkill = new DWButton[m_familySkill_numLeft];//按钮
		
		for(int i=0; i< m_familySkill_numLeft;i++){
			final int index = i;
			m_left_subItem[i] = new DWListSubItem();//构建subitem
			//技能图标
			m_left_imageSkill[i] = new DWImageBox(m_family_ditu);
			m_left_imageSkill[i].setNearAnchor(m_left_subItem[i], Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 0, 0);
			//技能真实图标
			m_bm_iconLeft[i] = IconManger.getInstance().getIcon(m_familySkill_iconNum[i]);
			m_left_skillIcon[i] = new DWImageBox(m_bm_iconLeft[i]);
			m_left_skillIcon[i].setNearAnchor(m_left_imageSkill[i], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
			//技能按钮
			m_left_buttonSkill[i] = new DWButton("不可激活", m_left_button01);
			m_left_buttonSkill[i].setDownImage(m_left_button02);
			//技能说明
			m_left_textSkill[i] = new DWTextbox(m_familySkill_miaoshu[i], m_family_leftListBox.getShowWidth() - m_left_imageSkill[i].getShowWidth() - m_left_buttonSkill[i].getShowWidth());
			m_left_textSkill[i].setNearAnchor(m_left_imageSkill[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
			
			m_left_textSkillimage[i] = new DWImageBox(m_left_image);
			m_left_textSkillimage[i].setShowWideHigh(m_family_leftListBox.getShowWidth() - m_left_imageSkill[i].getShowWidth() - m_left_buttonSkill[i].getShowWidth(), m_left_skillIcon[i].getShowHeight());
			m_left_textSkillimage[i].setNearAnchor(m_left_imageSkill[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
			
			m_left_buttonSkill[i].setNearAnchor(m_left_textSkill[i], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
			//add
			m_left_subItem[i].addControls(m_left_imageSkill[i]);
			m_left_subItem[i].addControls(m_left_skillIcon[i]);
			m_left_subItem[i].addControls(m_left_textSkillimage[i]);
			m_left_subItem[i].addControls(m_left_textSkill[i]);
			m_left_subItem[i].addControls(m_left_buttonSkill[i]);
			
			m_family_leftListBox.addSubItem(m_left_subItem[i]);
			
			//点击操作
			m_left_buttonSkill[index].addListener(new DWListener() {
				
				public void OnDoubleClick() {
				}
				
				public void OnClick() {
					if(m_family_stateLeft[index] == KEJIHUO){
						m_isFamily = true;
						m_isChick =index;
						m_num = m_familySkill_xiaohao[index];
						familySkillFrame(1,m_familySkill_key[index],m_familySkill_mingzi[index],m_familySkill_miaoshu[index],"<mark c=D9D919>需要消耗"+m_familySkill_xiaohao[index]+"点家族成长点数。</mark>",m_familySkill_iconNum[index]);
					}else{
						if(m_familySkill_level[index] > m_lucky_family_lv){
							DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您的家族目前等级不够，需要家族等级达到"+m_familySkill_level[index]+"级！");
						}else{
							DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "该技能需要的家族成长点数不足，需要"+m_familySkill_xiaohao[index]+"点家族成长点数");
						}
					}

					
				}
			});
		}
		//状态设置
		leftState();
	}
	/**状态设置*/
	private final static int KEJIHUO = 0;//可激活
	private final static int TIAOJIANBUZU = 1;//条件不足
	private final static int YIJIHUO = 2;//已经激活
	private void leftState(){
		for(int i =0;i<m_familySkill_numLeft;i++){
			if(m_family_stateLeft[i] == KEJIHUO){
				m_left_buttonSkill[i].setName("可激活");
				m_left_buttonSkill[i].setTouch(true);
				m_left_buttonSkill[i].setTextColor(Color.GREEN);
			}else if(m_family_stateLeft[i] == TIAOJIANBUZU){
				m_left_buttonSkill[i].setName("条件不足");
				m_left_buttonSkill[i].setTouch(true);
				m_left_buttonSkill[i].setTextColor(Color.RED);
				m_left_buttonSkill[i].setBackground(m_left_button02, false);
			}else if(m_family_stateLeft[i] == YIJIHUO){
				m_left_buttonSkill[i].setName("已激活");
				m_left_buttonSkill[i].setTouch(false);
				m_left_buttonSkill[i].setTextColor(Color.WHITE);
			}
		}
		if(m_familySkill_isZuZhang != 0){
			for(int i =0;i<m_familySkill_numLeft;i++){
				m_left_buttonSkill[i].setTouch(false);
			}
		}
	}
	
	
	/**刷新右侧的技能listbox*/
	private void refreshRightSkill(){
		if(m_family_rightListBox == null){
			return;
		}
		m_family_rightListBox.removeAllSubItem();
		int num = 0;
		if(m_familySkill_numRight%3 == 0){
			num = m_familySkill_numRight/3;
		}else{
			num = m_familySkill_numRight/3 +1;
		}
		
		m_right_subItem = new DWListSubItem[num];
		m_right_imageSkill = new DWImageBox[m_familySkill_numRight];
		m_right_buttonSkill = new DWButton[m_familySkill_numRight];
		m_right_skillIcon = new DWImageBox[m_familySkill_numRight];
		m_bm_iconRight = new Bitmap[m_familySkill_numRight];
		
		for(int i = 0;i < num;i++){
			m_right_subItem[i] = new DWListSubItem();		
		}
		
		for(int j = 0; j< m_familySkill_numRight;j++){
			final int index = j;
			m_right_imageSkill[j] = new DWImageBox(m_family_ditu);
			if(j%3 == 0){			
				m_right_imageSkill[j].setNearAnchor(m_right_subItem[j/3], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				
			}else if(j%3 == 1){
				m_right_imageSkill[j].setNearAnchor(m_right_subItem[j/3], Tools.LEFT_TOP, Tools.LEFT_TOP, m_family_rightListBox.getShowWidth()/3, 0);
			}else if(j%3 == 2){
				m_right_imageSkill[j].setNearAnchor(m_right_subItem[(j-2)/3], Tools.LEFT_TOP, Tools.LEFT_TOP, m_family_rightListBox.getShowWidth()*2/3, 0);
			}
			rightUI(j);
			m_right_buttonSkill[index].addListener(new DWListener() {
				
				public void OnDoubleClick() {
				}
				
				public void OnClick() {
					if(m_family_stateRight[index] == XIUXI){
						m_isFamily = false;
						m_isChick =index;
						m_num = m_ownSkill_xiaohao[index];
						familySkillFrame(0,m_ownSkill_key[index],m_ownSkill_mingzi[index],m_ownSkill_miaoshu[index],"<mark c=D9D919>需要消耗"+m_ownSkill_xiaohao[index]+"点帮贡点数。</mark>",m_ownSkill_iconNum[index]);
					}else if(m_family_stateRight[index] == BUKE){
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您的贡点不足，无法修的此技能");
					}else if(m_family_stateRight[index] == WANCHENG){
						
					}else if(m_family_stateRight[index] == SHIXIAO){
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "家族尚未激活次技能，因此技能暂不能生效。");
					}
				}
			});
		}
		for(int n = 0; n< num;n++){
			m_family_rightListBox.addSubItem(m_right_subItem[n]);
		}
		rightState();
	}
	/**右侧点击操作*/
	private void rightUI(int i){
		m_bm_iconRight[i] = IconManger.getInstance().getIcon(m_ownSkill_iconNum[i]);
		m_right_skillIcon[i] = new DWImageBox(m_bm_iconRight[i]);
		m_right_skillIcon[i].setNearAnchor(m_right_imageSkill[i], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		
		m_right_buttonSkill[i] = new DWButton("点击", m_right_button01);
		m_right_buttonSkill[i].setDownImage(m_right_button02);
		m_right_buttonSkill[i].setNearAnchor(m_right_imageSkill[i], Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, 0);
		

		m_right_subItem[i/3].addControls(m_right_imageSkill[i]);
		m_right_subItem[i/3].addControls(m_right_skillIcon[i]);
		m_right_subItem[i/3].addControls(m_right_buttonSkill[i]);
	}
	/**右侧状态*/
	private final static int XIUXI = 0;
	private final static int BUKE = 1;
	private final static int WANCHENG = 2;
	private final static int SHIXIAO = 3;
	private void rightState(){
		for(int i=0;i<m_familySkill_numRight;i++){
			if(m_family_stateRight[i] == XIUXI){
				m_right_buttonSkill[i].setName("修行");
				m_right_buttonSkill[i].setTouch(true);
				m_right_buttonSkill[i].setTextColor(Color.GREEN);				
			}else if(m_family_stateRight[i] == BUKE){
				m_right_buttonSkill[i].setName("不可");
				m_right_buttonSkill[i].setTouch(true);
				m_right_buttonSkill[i].setTextColor(Color.RED);
			}else if(m_family_stateRight[i] == WANCHENG){
				m_right_buttonSkill[i].setName("完成");
				m_right_buttonSkill[i].setTouch(false);
				m_right_buttonSkill[i].setTextColor(Color.WHITE);
			}else if(m_family_stateRight[i] == SHIXIAO){
				m_right_buttonSkill[i].setName("失效");
				m_right_buttonSkill[i].setTouch(true);
				m_right_buttonSkill[i].setTextColor(Color.GRAY);
			}
		}
	}
	
	private DWFrame m_familySkill_frame = null;
	private DWBackground m_familySkill_backGround = null;
	private Bitmap m_bm_backGround = null;
	private DWTextbox m_familySkill_name = null;
	private DWImageBox m_familySkill_image = null;
	private DWTextbox m_familySkill_shuoming = null;
	private DWTextbox m_familySkill_jiage = null;
	private DWButton m_familySkill_xuexi = null;
	private DWButton m_familySkill_fanhui = null;
	
	private DWImageBox m_xiaokuang_image = null;
	
	
	private boolean m_isFamily = false;//是否是家族技能
	private int m_isChick = 0;//点击的是哪一个
	private int m_num=0;//贡献点数
	/**
	 * 
	 * @param state//  0,个人开启  1 家族开启
	 * @param key//技能key
	 * @param name技能名称
	 * @param describe技能描述
	 * @param money需要贡献点
	 */
	private void familySkillFrame(int state,String key,String name,String describe,String money,int icon){
		final int stateSend = state;
		final String keySend = key;
		m_familySkill_frame = new DWFrame(m_family_TabControl.getShowWidth()/2, m_family_TabControl.getShowHeight()/2);
		m_familySkill_frame.setClickClose(false);
		
		m_familySkill_backGround = new DWBackground(m_bm_backGround,m_familySkill_frame.getShowWidth(), m_familySkill_frame.getShowHeight());
		m_familySkill_backGround.setNearAnchor(m_familySkill_frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_familySkill_frame.addControl(m_familySkill_backGround);
		
		m_familySkill_name = new DWTextbox(name);
		m_familySkill_name.setNearAnchor(m_familySkill_backGround, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 0);
		m_familySkill_frame.addControl(m_familySkill_name);
		
		m_familySkill_image = new DWImageBox(m_family_ditu);
		m_familySkill_image.setNearAnchor(m_familySkill_backGround, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
		m_familySkill_frame.addControl(m_familySkill_image);
		
		Bitmap  bm = IconManger.getInstance().getIcon(icon);
		m_xiaokuang_image = new DWImageBox(bm);
		m_xiaokuang_image.setNearAnchor(m_familySkill_image, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_familySkill_frame.addControl(m_xiaokuang_image);
		
		m_familySkill_shuoming = new DWTextbox("技能说明："+describe,m_familySkill_backGround.getShowWidth() - DWGameManager.Screen_Width*10/128);
		m_familySkill_shuoming.setNearAnchor(m_familySkill_image, Tools.LEFT_TOP, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height/72);
		m_familySkill_frame.addControl(m_familySkill_shuoming);
		
		m_familySkill_jiage = new DWTextbox(money,m_familySkill_backGround.getShowWidth()/2 - DWGameManager.Screen_Width/64);
		m_familySkill_jiage.setNearAnchor(m_familySkill_shuoming, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, DWGameManager.Screen_Height/72);
		m_familySkill_frame.addControl(m_familySkill_jiage);
		
		m_familySkill_fanhui = new DWButton("算了", m_right_button01);
		m_familySkill_fanhui.setDownImage(m_right_button02);
		m_familySkill_fanhui.setNearAnchor(m_familySkill_backGround, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -DWGameManager.Screen_Width/128, -DWGameManager.Screen_Height/72);
		m_familySkill_frame.addControl(m_familySkill_fanhui);
		m_familySkill_fanhui.addListener(new DWListener() {
			
			public void OnDoubleClick() {
			}
			
			public void OnClick() {
				DWControlsManager.getInstance().removeControl(m_familySkill_frame);
			}
		});
		
		if(stateSend == 1){
			m_familySkill_xuexi = new DWButton("激活", m_right_button01);
		}else{
			m_familySkill_xuexi = new DWButton("修行", m_right_button01);
		}
		
		m_familySkill_xuexi.setDownImage(m_right_button02);
		m_familySkill_xuexi.setNearAnchor(m_familySkill_fanhui, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, -DWGameManager.Screen_Width/128, 0);
		m_familySkill_frame.addControl(m_familySkill_xuexi);
		//族长学习技能
		m_familySkill_xuexi.addListener(new DWListener() {
			
			public void OnDoubleClick() {
				
			}
			
			public void OnClick() {
				DWGameManager.getInstance().getSendMessage().sendOpenFamilySkill((byte)stateSend, keySend);
				DWControlsManager.getInstance().removeControl(m_familySkill_frame);
			}
		});		
		DWControlsManager.getInstance().addControl(m_familySkill_frame);
	}
	
	/**************************************************************************************捐献帮贡*******************************************/
	private DWFrame m_list_frame = null;
	private DWTitle m_list_title = null;
	private DWImageBox m_list_close = null;
	private DWBackground m_list_background = null;
	private DWBackground[] m_list_background01 = new DWBackground[3];
	private Actor[] m_gongxian_actor = new Actor[3];
	private DWAnimationBox[] m_list_abox = new DWAnimationBox[3];
//	private DWBackground m_list_background02 = null;
//	private DWBackground m_list_background03 = null;
	private DWTextbox[] m_list_name = new DWTextbox[3];
	private final static String[] m_text_name = {"捐献金币","捐献元宝","捐献元宝"};
	private DWTextbox[] m_list_money = new DWTextbox[3];
	private final static String[] m_text_money = {"10000金币","1元宝","100元宝"};
	private DWTextbox[] m_list_button = new DWTextbox[3];
	private final static String[] m_list_str = {"捐献","捐献","捐献"};
	private DWTextbox[] m_list_tishi = new DWTextbox[3];
	private final static String[] m_text_tishi = {"每天只能捐献一次","每天只能捐献一次","每天只能捐献一次"};
	
	private Bitmap m_list_button01 = null;
	private Bitmap m_list_button02 = null;
	private Actor m_list_actot = null;
	private DWAnimationBox[] m_list_anBox =new DWAnimationBox[3];
	
	private void listFrame(){
		m_list_frame = new DWFrame(m_family_TabControl.getShowWidth(), m_family_TabControl.getShowHeight());
		
		m_list_background = new DWBackground(m_list_frame.getShowWidth(), m_list_frame.getShowHeight());
		m_list_background.setNearAnchor(m_list_frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_list_frame.addControl(m_list_background);
		
		m_list_title = new DWTitle("选择捐献", m_list_frame);
		m_list_frame.addControl(m_list_title);
		
		m_list_close = new DWImageBox(closeWimdow);
		m_list_close.setNearAnchor(m_list_title, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, 0, 0);
		m_list_frame.addControl(m_list_close);
		
		m_list_background01[0] = new DWBackground(m_list_background.getShowWidth()/3 - 20, m_list_background.getShowHeight() - 50);
		m_list_background01[0].setFill(true);
		m_list_background01[0].setNearAnchor(m_list_background, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 10, 0);
		m_list_frame.addControl(m_list_background01[0]);
		
		m_list_background01[1] = new DWBackground(m_list_background.getShowWidth()/3 - 20, m_list_background.getShowHeight() - 50);
		m_list_background01[1].setFill(true);
		m_list_background01[1].setNearAnchor(m_list_background01[0], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
		m_list_frame.addControl(m_list_background01[1]);
		
		m_list_background01[2] = new DWBackground(m_list_background.getShowWidth()/3 - 20, m_list_background.getShowHeight() - 50);
		m_list_background01[2].setFill(true);
		m_list_background01[2].setNearAnchor(m_list_background01[1], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
		m_list_frame.addControl(m_list_background01[2]);
		
		for(int i = 0;i<m_text_name.length;i++){
			final int index = i;
			m_list_abox[i] = new DWAnimationBox(m_gongxian_actor[i]);		
			m_list_name[i] = new DWTextbox(m_text_name[i]);
			m_list_money[i] = new DWTextbox(m_text_money[i]);
			m_list_button[i] = new DWTextbox("捐献");//new DWButton(m_list_str[i], m_list_button01);
			m_list_button[i].setTouchZoomIn(DWGameManager.Screen_Width*5/128, DWGameManager.Screen_Height*5/72);
//			m_list_button[i].setDownImage(m_list_button02);
			m_list_anBox[i] = new DWAnimationBox(m_list_actot);
			m_list_anBox[i].setTouch(false);
			m_list_tishi[i] = new DWTextbox(m_text_tishi[i],m_list_background01[i].getShowWidth());
			
			m_list_abox[i].setNearAnchor(m_list_background01[i], Tools.RIGHT_BOTTOM, Tools.RIGHT_VCENTER, -m_list_background01[i].getShowWidth()/3, 0);
			m_list_name[i].setNearAnchor(m_list_background01[i], Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, 0);
			m_list_money[i].setNearAnchor(m_list_name[i], Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height/16);
			m_list_button[i].setNearAnchor(m_list_abox[i], Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height/16);
			m_list_anBox[i].setNearAnchor(m_list_button[i], Tools.HCENTER_BOTTOM, Tools.HCENTER_VCENTER, 0, 0);
			m_list_tishi[i].setNearAnchor(m_list_background01[i], Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, 0);
			
			m_list_frame.addControl(m_list_abox[i]);
			m_list_frame.addControl(m_list_name[i]);
			m_list_frame.addControl(m_list_money[i]);
			m_list_frame.addControl(m_list_anBox[i]);
			m_list_frame.addControl(m_list_button[i]);
		
			m_list_frame.addControl(m_list_tishi[i]);
			
			m_list_button[index].addListener(new DWListener() {
				
				public void OnDoubleClick() {
				}
				
				public void OnClick() {
					if(index == 0){//金币
						juanFrame((byte)0, 10000,(byte)0);
					}else{
						if(index == 1){
							juanFrame((byte)1, 1,(byte)1);
						}else{
							juanFrame((byte)1, 100,(byte)2);
						}
					}	
					DWControlsManager.getInstance().removeControl(m_list_frame);	
				}
			});
			
		}		
		DWControlsManager.getInstance().addControl(m_list_frame);
		m_list_close.addListener(new DWListener() {
			
			public void OnDoubleClick() {
			}
			
			public void OnClick() {
				DWControlsManager.getInstance().removeControl(m_list_frame);	
			}
		});
	}
	/**
	 * 捐献界面
	 */
	private DWFrame m_juan_frame = null;
	private DWTitle m_juan_title = null;
	private DWImageBox m_juan_close = null;
	private DWBackground m_guan_beijing = null;
	private DWTextbox m_juan_miaoshu = null;
	private DWImageBox m_juan_left = null;
	private DWImageBox m_juan_right = null;
	private DWInputBox m_juan_input = null;
	private DWTextbox m_juan_huode = null;
	private DWTextbox m_juan_huode02 = null;
	private DWButton m_juan_ok = null;
	private DWTextbox m_juan_zhuyi = null;
	
	private long m_money =0;
	private int m_jishu = 1;
	
	
	private void juanFrame(byte state,long num,byte index){
		final int m_state = state;
		final long m_num = num;
		m_money = m_num;
		final int m_index = index;
		m_jishu = 1;
		m_juan_frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER);
		m_juan_title = new DWTitle("捐献帮贡", m_juan_frame);
		m_juan_frame.addControl(m_juan_title);
		
		m_juan_close = new DWImageBox(closeWimdow);
		m_juan_close.setNearAnchor(m_juan_title, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, 0, 0);
		m_juan_frame.addControl(m_juan_close);
		
		m_guan_beijing = new DWBackground(m_juan_frame.getShowWidth()-DWGameManager.Screen_Width*5/128, m_juan_frame.getShowHeight()-DWGameManager.Screen_Height*10/72);
		m_guan_beijing.setNearAnchor(m_juan_frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_juan_frame.addControl(m_guan_beijing);
		
		m_juan_miaoshu = new DWTextbox("aaaaaaaaaaaaaaaaaaa");
		m_juan_miaoshu.setNearAnchor(m_guan_beijing, Tools.HCENTER_TOP, Tools.HCENTER_TOP, 0, DWGameManager.Screen_Height*5/72);
		m_juan_frame.addControl(m_juan_miaoshu);
		
		m_juan_input = new DWInputBox(m_guan_beijing.getShowWidth()/2, m_juan_miaoshu.getShowHeight(), m_juan_frame);
		m_juan_input.setText(String.valueOf(m_num));
		m_juan_input.setTouch(false);
		m_juan_input.setNearAnchor(m_juan_miaoshu, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height*5/72);
		m_juan_frame.addControl(m_juan_input);
		
		m_juan_left = new DWImageBox(beforePage);
		m_juan_left.setNearAnchor(m_juan_input, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, -DWGameManager.Screen_Width/128, 0);
		m_juan_frame.addControl(m_juan_left);
		
		m_juan_right = new DWImageBox(nextPage);
		m_juan_right.setNearAnchor(m_juan_input, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, DWGameManager.Screen_Width/128, 0);
		m_juan_frame.addControl(m_juan_right);
		
		m_juan_huode = new DWTextbox("可以获得帮贡点");
		m_juan_huode.setNearAnchor(m_juan_input, Tools.HCENTER_TOP	, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height*2/72);
		m_juan_frame.addControl(m_juan_huode);
		
		m_juan_huode02 = new DWTextbox("可以获得家族成长点");
		m_juan_huode02.setNearAnchor(m_juan_huode, Tools.HCENTER_TOP	, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height/72);
		m_juan_frame.addControl(m_juan_huode02);
		
		m_juan_ok = new DWButton("确定", m_right_button01);
		m_juan_ok.setDownImage(m_right_button02);
		m_juan_ok.setNearAnchor(m_juan_huode02, Tools.HCENTER_TOP	, Tools.HCENTER_BOTTOM, 0, DWGameManager.Screen_Height*4/72);
		m_juan_frame.addControl(m_juan_ok);
		
		m_juan_zhuyi = new DWTextbox("注意：每天只能捐献一次");
		m_juan_zhuyi.setNearAnchor(m_guan_beijing, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, 0);
		m_juan_frame.addControl(m_juan_zhuyi);
				
		if(index == 0){//0是金币
			m_juan_miaoshu.setText("可以捐献"+num+"金币的倍数");
			m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_jinbi_num01+"点");
			m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_jinbi_num02+"点");
		}else {
			m_juan_miaoshu.setText("可以捐献"+num+"元宝的倍数");
			if(index == 1){
				m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_yuanbao_numMin01+"点");
				m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_yuanbao_numMin02+"点");
			}else{
				m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_yuanbao_numMax01+"点");
				m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_yuanbao_numMax02+"点");
			}			
		}
		DWControlsManager.getInstance().addControl(m_juan_frame);
		
		m_juan_left.addListener(new DWListener() {
			
			public void OnDoubleClick() {
			}
			
			public void OnClick() {
				if(m_jishu <= 1){
					return;
				}else{
					m_jishu--;
					m_money = m_num*m_jishu;
					m_juan_input.setText(String.valueOf(m_money));
					if(m_index == 0){//0是金币  可以封装下
						m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_jinbi_num01*m_jishu+"点");
						m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_jinbi_num02*m_jishu+"点");
					}else {
						if(m_index == 1){
							m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_yuanbao_numMin01*m_jishu+"点");
							m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_yuanbao_numMin02*m_jishu+"点");
						}else{
							m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_yuanbao_numMax01*m_jishu+"点");
							m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_yuanbao_numMax02*m_jishu+"点");
						}			
					}
				}
			}
		});
		m_juan_right.addListener(new DWListener() {
			
			public void OnDoubleClick() {
			}
			
			public void OnClick() {
//				if(m_money>=999999999){
//					
//				}else{
					m_jishu++;
					m_money = m_num*m_jishu;
					m_juan_input.setText(String.valueOf(m_money));
					if(m_index == 0){//0是金币    
						m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_jinbi_num01*m_jishu+"点");
						m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_jinbi_num02*m_jishu+"点");
					}else {
						if(m_index == 1){
							m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_yuanbao_numMin01*m_jishu+"点");
							m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_yuanbao_numMin02*m_jishu+"点");
						}else{
							m_juan_huode.setText("可以获得帮贡"+m_familrSkill_role.m_yuanbao_numMax01*m_jishu+"点");
							m_juan_huode02.setText("可以获得家族成长"+m_familrSkill_role.m_yuanbao_numMax02*m_jishu+"点");
						}			
					}
//				}
			}
		});
		
		m_juan_ok.addListener(new DWListener() {
			
			public void OnDoubleClick() {
			}
			
			public void OnClick() {
				DWGameManager.getInstance().getSendMessage().sendJuanXianBangGong((byte)m_state, m_money);
				DWControlsManager.getInstance().removeControl(m_juan_frame);
			}
		});
		
		m_juan_close.addListener(new DWListener() {
			
			public void OnDoubleClick() {
			}
			
			public void OnClick() {
				DWControlsManager.getInstance().removeControl(m_juan_frame);
			}
		});
	}
	
	
	/**
	 * 家族技能的相关指令
	 */
	private int m_familySkill_isZuZhang = 0;
	private long m_familySkill_chengzhangdian = 0;
	private long m_familySkill_gongxiandian = 0;
	//家族
	private String[] m_familySkill_key;
	private int[] m_familySkill_level;
	private String[] m_familySkill_miaoshu;
	private String[] m_familySkill_mingzi;
	private int[] m_familySkill_xiaohao;
	private int[] m_familySkill_iconNum;
	private int[] m_family_stateLeft;
	//个人
	private String[] m_ownSkill_key;
	private String[] m_ownSkill_mingzi;
	private String[] m_ownSkill_miaoshu;
	private int[] m_ownSkill_xiaohao;
	private int[] m_ownSkill_iconNum;
	private int[] m_family_stateRight;
	//
//	public int m_jinbi_num01 = 0;
//	public int m_jinbi_num02 = 0;
//	public int m_yuanbao_numMin01 = 0;
//	public int m_yuanbao_numMin02 = 0;
//	public int m_yuanbao_numMax01 = 0;
//	public int m_yuanbao_numMax02 = 0;
	
	private Role m_familrSkill_role = DWGameManager.getInstance().m_role;
	
	public void recvFamilySkill(DataInputStream dis) throws IOException{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		try {
			m_familySkill_isZuZhang = dis.readByte();//0是族长
			m_familySkill_chengzhangdian = dis.readLong();//家族成长点
			m_familySkill_gongxiandian = dis.readLong();//个人贡献点
			
			m_familySkill_numLeft = dis.readByte();//家族技能size
			m_familySkill_key = new String[m_familySkill_numLeft];
			m_familySkill_level = new int[m_familySkill_numLeft];
			m_familySkill_miaoshu = new String[m_familySkill_numLeft];
			m_familySkill_xiaohao = new int[m_familySkill_numLeft];
			m_familySkill_iconNum = new int[m_familySkill_numLeft];//技能图标
			m_family_stateLeft = new int[m_familySkill_numLeft];//技能的状态
			m_familySkill_mingzi = new String[m_familySkill_numLeft];
			for(int i=0; i< m_familySkill_numLeft;i++){
				m_familySkill_key[i] =  dis.readUTF();//技能key
				m_familySkill_mingzi[i] = dis.readUTF();
				m_familySkill_level[i] = dis.readByte();//家族技能开启级别限制
				m_familySkill_miaoshu[i] = dis.readUTF();//技能描述
				m_familySkill_xiaohao[i] = dis.readInt();//消耗贡献点
				m_familySkill_iconNum[i] = dis.readShort();//技能图标
				m_family_stateLeft[i] = dis.readByte();//技能的状态
			}
			
			m_familySkill_numRight = dis.readByte();//个人技能size
			m_ownSkill_key = new String[m_familySkill_numLeft];
			m_ownSkill_miaoshu = new String[m_familySkill_numLeft];
			m_ownSkill_xiaohao = new int[m_familySkill_numLeft];
			m_ownSkill_iconNum = new int[m_familySkill_numLeft];//技能图标
			m_family_stateRight = new int[m_familySkill_numLeft];//技能的状态
			m_ownSkill_mingzi = new String[m_familySkill_numLeft];//技能的状态
			for(int i =0;i<m_familySkill_numRight;i++){
				String s = dis.readUTF();
				m_ownSkill_key[i] =  s;//技能key
				m_ownSkill_mingzi[i] = dis.readUTF();
				m_ownSkill_miaoshu[i] = dis.readUTF();//技能描述
				m_ownSkill_xiaohao[i] = dis.readInt();//消耗贡献点
				m_ownSkill_iconNum[i] = dis.readShort();//技能图标
				m_family_stateRight[i] = dis.readByte();//技能的状态
			}			
			familySkill();
		} catch (Exception e) {
			Tools.debug(e);
		}
	}
	/**
	 * 第二次开启家族技能
	 */
	public void recvFamilyOpenSkillAgain(DataInputStream dis) throws IOException{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		try {
			m_familySkill_isZuZhang = dis.readByte();//0是族长
			m_familySkill_chengzhangdian = dis.readLong();//家族成长点
			m_familySkill_gongxiandian = dis.readLong();//个人贡献点
			m_familySkill_numLeft = dis.readByte();//家族技能size
			
			for(int i=0; i< m_familySkill_numLeft;i++){
				m_familySkill_key[i] =  dis.readUTF();//技能key
				m_family_stateLeft[i] = dis.readByte();//技能的状态
			}
			familySkill();
		} catch (Exception e) {
			Tools.debug(e);
		}
	}
	
	/**
	 * 学习家族技能的相关指令0为个人    1为家族
	 */
	public void recvFamilyStudySkill(DataInputStream dis) throws IOException{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_家族);
		try {
			byte state = dis.readByte();//0是成功
			if(state == 0){
				if(m_isFamily){//家族
					m_family_stateLeft[m_isChick] = YIJIHUO;
					m_left_buttonSkill[m_isChick].setName("已激活");
					m_left_buttonSkill[m_isChick].setTouch(false);
					m_left_buttonSkill[m_isChick].setTextColor(Color.WHITE);
					m_familySkill_chengzhangdian = m_familySkill_chengzhangdian - m_num;
					m_familySkill_familyNum.setText("家族成长点："+m_familySkill_chengzhangdian);
				}else{
					m_family_stateRight[m_isChick] = WANCHENG;
					m_right_buttonSkill[m_isChick].setName("完成");
					m_right_buttonSkill[m_isChick].setTouch(false);
					m_familySkill_gongxiandian = m_familySkill_gongxiandian - m_num;
					m_familySkill_ownNum.setText("个人贡献值："+m_familySkill_gongxiandian);
				}
				m_familySkill_numRight = dis.readByte();//家族技能size
				for(int i =0;i<m_familySkill_numRight;i++){
					String s = dis.readUTF();
					m_ownSkill_key[i] =  s;//技能key
					m_ownSkill_mingzi[i] = dis.readUTF();
					m_ownSkill_miaoshu[i] = dis.readUTF();//技能描述
					m_ownSkill_xiaohao[i] = dis.readInt();//消耗贡献点
					m_ownSkill_iconNum[i] = dis.readShort();//技能图标
					m_family_stateRight[i] = dis.readByte();//技能的状态
				}
				
				familySkill();
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "开启技能成功");
			}else if(state == 1){
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "家族成长值不够");
			}else if(state == 2){
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "个人贡献点不够");
			}else if(state == 3){
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "不够开启条件");
			}else if(state == 4){				
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "未知错误");
			}
			
		} catch (Exception e) {
			Tools.debug(e);
		}
	}
	/**
	 * 捐献
	 */
	public void recvFamilyJuanXian(DataInputStream dis) throws IOException{
		try {
			byte state = dis.readByte();
			if(state == 0){
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "未知错误");
			}else if(state == 1){
				m_familySkill_chengzhangdian = dis.readLong();//家族成长点
				m_familySkill_gongxiandian = dis.readLong();//个人贡献点
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, " 捐献成功");
			}else if(state == 2){
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, " 金币不足");
			}else if(state == 3){
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "元宝不足");
			}else if(state == 4){				
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "一天只能捐献一次");
			}
		} catch (Exception e) {
			Tools.debug(e);
		}
	}
	
	public void recvFamilyZhi(DataInputStream dis) throws IOException{
		try {
			m_familySkill_chengzhangdian = dis.readLong();//家族成长点
			m_familySkill_gongxiandian = dis.readLong();//个人贡献点			
		} catch (Exception e) {
			Tools.debug(e);
		}
	}
}
